如何使用JDBc连接mysql谢谢 jdbc:mysql://"+host+":"+port+"/"+db_name 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.sql.*;public class Cnn{ public static void main(String args[]) { String driver="你的驱动位置"; String url="jdbc:mysql://localhost:3306/你的数据库名"; String user="你的用户名"; String pwd="密码"; try { Class.forName(driver); } catch(Exception E) { System.out.println("Fail to load Driver"+driver); E.printStackTrace(); } try { Connection con=DriverManager.getConnection(url,user,pwd); while(con!isClose()) { System.out.println("Success"); } con.close(); } catch(SQLException SE) { SE.printStackTrace(); } }} for example:private static String s_JDBCUrl = "jdbc:mysql://" + DB_HOST + ":" + JDBC_PORT + "/" + DB_NAME; private static final String DB_HOST = "localhost";private static final String JDBC_PORT = "3306";private static final String DB_NAME = "vap";connection = DriverManager.getConnection(s_JDBCUrl, user, password); 求助:orcale库迁到mysql后性能低下问题~~~~ MySql配置文件my.cnf下划线 大家在生产库都用什么监控MYSQL啊 求助:mysql语法错误 mysql装了N次还是出错(图) MySQL 导入数据库出现问题 MYSQL 删除数据库表中重复的记录,只保留一个,怎么做? 紧急:Unix/Linux平台下PHP+MySQL做后台数据库问题请教! 想学习数据库设计,从哪里入手? 如何导入更新数据库中的存储过程 急寻apache+php+mysql程序员 在linux下 找不到mysql.sock怎么办?
public class Cnn
{
public static void main(String args[])
{
String driver="你的驱动位置";
String url="jdbc:mysql://localhost:3306/你的数据库名";
String user="你的用户名";
String pwd="密码";
try
{
Class.forName(driver);
}
catch(Exception E)
{
System.out.println("Fail to load Driver"+driver);
E.printStackTrace();
}
try
{
Connection con=DriverManager.getConnection(url,user,pwd);
while(con!isClose())
{
System.out.println("Success");
}
con.close();
}
catch(SQLException SE)
{
SE.printStackTrace();
}
}
}
private static String s_JDBCUrl = "jdbc:mysql://" + DB_HOST + ":" + JDBC_PORT + "/" + DB_NAME;
private static final String DB_HOST = "localhost";
private static final String JDBC_PORT = "3306";
private static final String DB_NAME = "vap";
connection = DriverManager.getConnection(s_JDBCUrl, user, password);