新开了个项目可以连mysql,但是原本的项目连接不上去
package com.example.sqltest.Tool;
import java.sql.Connection;
import java.sql.DriverManager;
public class SqlTool {
private static String driver;
private static String url;
private static String username;
private static String password;
private static Connection connection;
public static void getconcetion(){
Thread tg=new Thread(new Runnable() {
@Override
public void run() {
try {
driver="com.mysql.jdbc.Driver";
url="jdbc:mysql://172.18.56.110:3306/exam";
username="bill";
password="111111";
Class.forName(driver);
connection= DriverManager.getConnection(url,username,password);
for(int i=0;i<100;i++) System.out.println("线程加载"+i);
System.out.println(String.valueOf(connection));
}catch (Exception e){
e.printStackTrace();
}
}
});
tg.start();
}
}
标签:总结,username,String,private,static,mysql,今日,public From: https://www.cnblogs.com/liyiyang/p/17155537.html