To connect to the database
//step-1: load the driver
Class.forName(db_DriverName);
//step-2: get the connection
connection=DriverManager.getConnection(db_URL, db_Username, db_Password);
//step-3: write your queries
String insertData="";
statement=connection.createStatement();
//step-4: execute your queries/statements
statement.executeUpdate(insertData);
//step-5: close the connection
if(statement!=null)
{
statement.close();
}
if(connection!=null)
{
connection.close();
}
|