JAVA - JDBC and VB - ADO - NET Comparison
JAVA - JDBC and VB - ADO - NET Comparison
NET
1. Import java.sql.*; Using System.Data.SqlClient;
2. - Load the drviver Add necessary references
- Register the Driver
Class.ForName(“com.mysql.jdbc.Driver”); OR
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
3. Create connection Instantiate the connection
Connection con = SqlConnection conn = new
DriverManager.getConnection(“URL”,”UserName”,”Psw”) SqlConnection(
"Data
Connection SQlCnn = Source=(local);Initial
DriverManager.getConnection("jdbc:sqlserver://127.0.0.1; Catalog=Northwind;Integrated
databaseName= VBDtbthoby; user= User1; password= zxc"); Security=SSPI");
4. Create statement // 2. Open the connection
Statement st = con.Createstatement(); conn.Open();
// 5. Close the
connection
if (conn != null)
{
conn.Close();
}