2022年5月20日 星期五

Java call SQL

0


Class.forName(GlobalConstants.DB_DRIVER);
Connection conn = DriverManager.getConnection(GlobalConstants.DB_URL,GlobalConstants.DB_USER,GlobalConstants.DB_PWD);
 
String sql = "SELECT DISTINCT location FROM servicedoffices ORDER BY location";
PreparedStatement stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();

  Vector locationList = new Vector();
  while(rs.next()){
    locationList.add(rs.getString("location"));
    locationList.add(rs.setTimestamp("Time"));

  }
rs.close();
stmt.close();
conn.close();



0 意見:

張貼留言