String sq="select max(id) as idd from wglmessage";
我是这样做的,但不知道该如何去取得idd的值,请教了,各位!
like this?you can have a try~~
[CODE]import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class TestTest{
public static void main(String[] args){
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
Connection con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;databasename=pubs","flash7758","198244");
Statement stm=con.createStatement();
ResultSet rs=stm.executeQuery("select max(job_id) as iid from JObs");
while(rs.next()){
System.out.println(rs.getInt("iid"));
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
[/CODE]