简单连接数据库的重要语句
private static final String driver = "oracle.jdbc.driver.OracleDriver";
private static final String url = "jdbc:oracle:thin:@10.10.12.92:1521:orcl";
private static final String userName = "ubas";
private static final String password = "ubas";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "select * from ...";
try{
conn = getConn();
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next()) {
id = rs.getString("id");
start = rs.getString("req_start_date");
}
String updatesql = "update uba_user_behavior set req_end_date=to_date('"
+ end_date
+ "','yyyy-mm-dd hh24:mi:ss'),time_length='"
+ jg_date
+ "' where id='" + id + "'";
System.out.println(updatesql);
pstmt = conn.prepareStatement(updatesql);
}
}catch(Exception e){
e.printStackTrace();
}finally{
closeAll(conn,pstmt,rs);
}
猜你喜欢
转载自yangsongjing.iteye.com/blog/1498166
今日推荐
周排行