如何使用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); 选择多列,某列排除重复,不用子查询的一句sql mysql如何查看在不同时刻数据库表中数据的变换情况 mysql 百分比查询 如何建立数据库表空间 求个行转列的SQL 请问Mysql数据库如何加密 求一条select语句,统计方面的 请教一个sql语句 已经按月分表后的流水表,数据量还是很大,要生成统计信息,该怎么优化 SQL数据库SSL未被使用 急寻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);