Example 7 38   MySQL JDBC driver loading and connection
import java.sql.*;
public class MySQLClient
{
    public static void main (String[] args) throws Exception
    {
        // load the driver
        Class.forName ("com.mysql.jdbc.Driver");
        // connect to database
        Connection conn = DriverManager.getConnection 
("jdbc:mysql://localhost/itsodb", "userid", "passwd");
        //...
    }
}
Example 7 39   DB2 JDBC driver loading and connection
import java.sql.*;
public class DB2Client
{
    public static void main (String[] args) throws Exception
    {
        // load the driver
        Class.forName ("COM.ibm.db2.jdbc.net.DB2Driver");
        // connect to database
        Connection conn = DriverManager.getConnection 
("jdbc:db2://localhost/itsodb2", "userid", "passwd");
        //...
    }
}
Calling query statement
As both DB2 and MySQL follow the SQL standard and the JDBC specification, 
the query execution code will not change much. Once a connection is 
 Chapter 7. Application porting 
193






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved