摘要:addSQLServer
java build path>>>>sqljdbc4.jar
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class addSQLServer {
/**
* @param args
*/
public static void main(String[] args) {
//設定jdbc連結字串,請依你的SQL Server設定值修改
String conUrl = "jdbc:sqlserver://10.12.208.114:1433;DatabaseName=afa;user=ydd;password=P@ssw0rd;"; //for jdbc 2.0
Connection con = null;
try {
//註冊JODBC類
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
con = DriverManager.getConnection(conUrl);
for (int i=0;i<980000;i++){
Statement stmt = con.createStatement();
//System.out.println("Start add" +i);
String SQL = "insert into YDD_RESOURCE_DESCRIPTION "
+ "(RESOURCE_ID,RESOURCE_TYPE_ID ,RESOURCE_TYPE_PROPERTY,RESOURCE_DESCRIPTION_VALUE) "
+" values ('1','6','DbType','SQLSERVER') ";
stmt.execute(SQL);
SQL = "insert into YDD_RESOURCE_DESCRIPTION "
+ "(RESOURCE_ID,RESOURCE_TYPE_ID ,RESOURCE_TYPE_PROPERTY,RESOURCE_DESCRIPTION_VALUE) "
+" values ('1','6','DbCd','cd') ";
stmt.execute(SQL);
SQL = "insert into YDD_RESOURCE_DESCRIPTION "
+ "(RESOURCE_ID,RESOURCE_TYPE_ID ,RESOURCE_TYPE_PROPERTY,RESOURCE_DESCRIPTION_VALUE) "
+" values ('1','6','TableCd','TableCd') ";
stmt.execute(SQL);
SQL = "insert into YDD_RESOURCE_DESCRIPTION "
+ "(RESOURCE_ID,RESOURCE_TYPE_ID ,RESOURCE_TYPE_PROPERTY,RESOURCE_DESCRIPTION_VALUE) "
+" values ('1','6','TableNm','TableNm') ";
stmt.execute(SQL);
stmt.close();
}
System.out.println("finish");
//循環搜尋結果,請依你的資料庫來作提取資料欄位,以將下面的資料欄位對映你的資料欄位
// int i=0;
// while (rs.next()) {
// i++;
// System.out.println("no="+ i +" :"+rs.getString("RESOURCE_TYPE_PROPERTY") + ", " + rs.getString("RESOURCE_DESCRIPTION_VALUE"));
// }
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}