做点Postgresql笔记
做点Postgresql笔记没错这时本博主的新坑,而且挖的好辛苦:
select taxiNumber from taxiinfo
时,就会报出错误,表示没有此字段,因此只能暂用:` select * from taxiinfo
然后再在代码中取结果的不同字段(取我想要的那个字段),这样把结果全部查出的方式应该是降低了代码的执行效率的。
connection c = null;
statement stmt = null;
try{
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://...","postgres","password");
stmt = c.createStatement();
...
String insertsql = "insert into ... values ";
for(int i:insertListLength-2)
insertsql += "(insertList[i].attribute1,insertList[i].attribute2,insertList[i].attribute3),...,insertList[i].attributen),";
insertsql += "(insertList[insertListLength-1].attribute1,insertList[insertListLength-1].attribute2,insertList[insertListLength-1].attributen);";
stmt.executeUpdate(insertsql);
...
}catch(Exception e){
c.rollback();
}finally{
stmt.close();
c.close();
}
代码是我怕遗忘进行的记录,可不看。
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |