Import Java. SQL. * ;
Public Class DB
{
Public Static Void Main (string [] ARGs)
{
Try
{
// Connect to an SQL Server 2005 instanceCode
Class. forname ( " Com. Microsoft. sqlserver. JDBC. sqlserverdriver " ). Newinstance ();
String URL = " JDBC: sqlserver: // localhost: 1433; databasename = demo " ;
// Pubs for your database
String user = " SA " ;
String Password = " Zxm10 " ;
Connection Conn = Drivermanager. getconnection (URL, user, password );
Statement stmt = Conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );
String SQL = " Select * From t_user " ;
Resultset rs = Stmt.exe cutequery (SQL );
While (Rs. Next ())
{
System. Out. println ( " The first field is: " + Rs. getstring ( 1 ));
System. Out. println ( " The second field is: " + Rs. getstring ( 2 ));
}
Rs. Close ();
Stmt. Close ();
Conn. Close ();
/* Connect to the SQL Server 2000 instance code
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 = "hxh ";
Connection conn = drivermanager. getconnection (URL, user, password );
Statement stmt = conn. createstatement (resultset. type_scroll_sensitive, resultset. concur_updatable );
String SQL = "select * from jobs ";
Resultset rs1_stmt.exe cutequery (SQL );
While (Rs. Next ())
{
System. Out. println ("the first field is:" + Rs. getstring (1) + "<br> ");
System. Out. println ("the second field is:" + Rs. getstring (2) + "<br> ");
}
Rs. Close ();
Stmt. Close ();
Conn. Close (); */
System. Out. println ( " Asdfas " );
}
Catch (Exception ex)
{
System. Out. Print ( " Error. " + Ex. getmessage ());
}
}
}