1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

JDBC Tutorials

What are the steps in the JDBC connection?

Steps are :
1.    Load or register the driver with Class.forName().
2.    Establish Connection with the database with Connection Interface.
3.    Create Statement objects for Queries.
4.    Execute the statements which may or may not return ResultSet.
5.    Manipulate the ResultSet.
6.    Close the Statements and Connection objects.

Example :
public class TestJDBC {

public static void main(String[] args) {
try {
//Step 1 : Register the database driver by using :

//Class.forName(\" driver classs for that specific database\" );

Class.forName("com.mysql.jdbc.Driver");



//Step 2 : Now create a database connection using :

//Connection con = DriverManager.getConnection(url,username,password);

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/art1",art1,art1);



//Step 3: Now Create a query using :

Statement stmt = Connection.Statement(\"select EMP_NAME from EMP\");



//Step 4 : Exceute the query :

ResultSet rs = stmt.exceuteQuery();

while(rs.next()){



System.out.println(rs.getString(EMP_NAME));



}
catch (Exception e) {
e.printStackTrace();
}

}

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy