hi,
i have this code:
String sqlString = "select * from Customer where CustomerID = ?";
PreparedStatement pstmt = con.prepareStatement(sqlString);
pstmt.setString(1, "cust001");
ResultSet rs = pstmt.executeQuery();
i want to check if the customer id cust001 exists in the database. how can i do it? what do i need to do with the result set?
thanks,
cristine
Comments
rs = stmt.executeQuery(sql);
ResultSetMetaData rsmd = rs.getMetaData();
int numOfCol = rsmd.getColumnCount();
data = new Vector();
while(rs.next()){
record = new String[numOfCol];
for(int i = 0; i < numOfCol; i++){
record[i] = cString(rs.getString(i+1));
}
data.add(record);
}
Also, make sure you close ResultSet right after you got the data and moved it. Don't leave it open.
: hi,
:
: i have this code:
:
: String sqlString = "select * from Customer where CustomerID = ?";
: PreparedStatement pstmt = con.prepareStatement(sqlString);
: pstmt.setString(1, "cust001");
: ResultSet rs = pstmt.executeQuery();
:
: i want to check if the customer id cust001 exists in the database. how can i do it? what do i need to do with the result set?
:
: thanks,
:
: cristine
:
:
: