JAVA用JDBC和jtds向SQL SERVER中插入1百万条数据,插到3千条就提示:Network error IOException: Address already in use: connect(JTDS)和error socket
插入代码:
public void executeInsert(String sql) throws SQLException {
try {
conn = DriverManager.getConnection(url,username,password);
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println("DBconn.executeUpdate:" + ex.getMessage());
}
}
插入代码:
public void executeInsert(String sql) throws SQLException {
try {
conn = DriverManager.getConnection(url,username,password);
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
pstmt.close();
conn.close();
} catch (SQLException ex) {
System.err.println("DBconn.executeUpdate:" + ex.getMessage());
}
}
try {
conn = DriverManager.getConnection(url,username,password);
pstmt = conn.prepareStatement(sql);
int sqlCount = 0;
if (sqlList!= null) {
sqlCount = sqlList.size();
} String sql = null;
for (int i=0;i<=sqlCount;i++) {
sql = sqlList.get(i);
pstmt = conn.prepareStatement(sql);
pstmt.executeUpdate();
}
} catch (SQLException ex) {
System.err.println("DBconn.executeUpdate:" + ex.getMessage());
} finally {
if (pstmt != null) {pstmt.close();}
if (conn != null) {conn.close();}
}
}
}
没有做过具体的任务就不要乱说话!
你们为什么要说是连接的问题?
为什么要说是代码的问题?
为什么就不可以说是SQLSERVER的问题!
8楼的朋友,你做过具体的实验吗?
我打赌你没有!
我们要事实就事!我也遇到过这样的问题,我的解决方法就是用两台电脑来实现数据的COPY!
QQ:469208018