Import java. SQL .*;
Import com. Microsoft. sqlserver. JDBC .*;
Public class main {
Public static void main (string [] ARGs ){
System. Out. Print ("Hello world! ");
Int COUNT = 0;
For (INT I = 0; I {
Count + = 1;
}
System. Out. Print ("N" + count );
/*
Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver"). newinstance ();
String url = "JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = pubs ";
// Pubs for your database
String user = "sa ";
String Password = "";
Connection conn = drivermanager. getconnection (URL, user, password );
Statement stmt = conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );
String SQL = "select * from test ";
Resultset rs = stmt.exe cutequery (SQL );
While (Rs. Next ()){
System. Out. Print ("n your first field content is:" + Rs. getstring (1 ));
System. Out. Print ("n your second field content is:" + Rs. getstring (2 ));
}
System. Out. Print ("database operation successful, congratulations ");
Rs. Close ();
Stmt. Close ();
Conn. Close ();
*/
// Declare the JDBC objects.
Connection con = NULL;
Callablestatement cstmt = NULL;
Resultset rs = NULL;
Try {
// Establish the connection.
Sqlserverdatasource DS = new sqlserverdatasource ();
DS. setuser ("sa ");
DS. setpassword ("ruanyu ");
DS. setservername ("home \ sqlexpress ");
DS. setportnumber (1433 );
DS. setdatabasename ("adventureworks ");
Con = Ds. getconnection ();
// Execute a stored procedure that returns some data.
Cstmt = con. preparecall ("{call DBO. uspgetemployeemanagers (1 )}");
// Cstmt. setint (1, 10 );
Rs = cstmt.exe cutequery ();
// Iterate through the data in the result set and display it.
While (Rs. Next ()){
System. Out. println ("Employee:" + Rs. getstring ("lastname") +
"," + Rs. getstring ("firstname "));
System. Out. println ("Manager:" + Rs. getstring ("managerlastname") +
"," + Rs. getstring ("managerfirstname "));
System. Out. println ();
}
}
// Handle any errors that may have occurred.
Catch (exception e ){
E. printstacktrace ();
}
Finally {
If (RS! = NULL) Try {Rs. Close ();} catch (exception e ){}
If (cstmt! = NULL) Try {cstmt. Close ();} catch (exception e ){}
If (con! = NULL) Try {con. Close ();} catch (exception e ){}
System. Exit (1 );
}
}
}