?? dbconnect.java
字號:
package apriori;
import java.sql.*;
public class DBConnect {
public static Connection conn = null;
public static Statement statement=null;
public static void closeResource() {
try {
statement.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 使用DriverManager獲取數據庫連接
*/
public static void getConnection() throws Exception {
String driver = "org.gjt.mm.mysql.Driver";
String urlString = "jdbc:mysql://localhost/test";
String user = "root";
String pwd = "root";
Class.forName(driver);
conn = DriverManager.getConnection(urlString, user, pwd);
statement=conn.createStatement();
}
public static void main(String[] args){
try {
DBConnect.getConnection();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
for(int i=0;i<100000;i++){
int a = (int)(Math.random()*25);
int b = (int)(Math.random()*100000);
//char ch = (char)('a'+ a);
String sql = "insert into apriori(tid,item) values("+b+",'"+a+"')";
System.out.println(sql);
try {
DBConnect.statement.execute(sql);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -