日期:2014-05-20 浏览次数:20753 次
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class test {
public static void main(String[] args) {
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception ex) {
ex.printStackTrace();
}
try {
@SuppressWarnings("unused")
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydata?utf-8","root","dh");
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
}