?? db.java
字號(hào):
package cn.yang.novel.db;
import java.sql.*;
import cn.yang.novel.properties.*;
public class Db {
public Connection getMysqlConnect() throws Exception
{
String db="mysql";
String server = "192.168.1.101";
String user = "root";
String password = "12345678";
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String arg = "jdbc:mysql://" + server + "/" + db
+ "?useUnicode=true&characterEncoding=utf-8";
return DriverManager.getConnection(arg, user, password);
}
public Connection getConnection() {
String server = Proper.get_SERVER();
String driver = Proper.get_DRIVER();
String password = Proper.get_PASSWORD();
String username = Proper.get_USERNAME();
Connection conn = null;
try {
System.out.println("drive:" + server);
Class.forName(server).newInstance();
System.out.println("server:" + driver + ",connecdt...");
conn = DriverManager.getConnection(driver, username, password);
System.out.println("connect...ok");
return conn;
} catch (Exception e) {
e.printStackTrace();
return conn;
}
}
public void close(Connection con) {
try {
con.clearWarnings();
} catch (Exception e) {
e.printStackTrace();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -