Tuesday, January 4, 2011

Different Ways To Create Connection In Java with Different Database


1.MS-Access
Class.forName(sun.jdbc.odbc.JdbcOdbcDriver);
Connection con=DriverManager.getConnection(jdbc:odbc:<databaseName>);
2. MySQL
Class.forName(com.mysql.jdbc.Driver);
Connection con=DriverManager.getConnection(“jdbc:mysql://localhost/<databasename>?user=root&password=admin”);
3.Oracle
Class.forName("oracle.jdbc.driver.OracleDriver");
 Connection    con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:<databasename>",
        <userid>,<password>);

No comments:

Post a Comment

Spring Boot Config Server and Config Client.

 In Spring cloud config we can externalise our configuration files to some repository like GIT HUT, Amazon S3 etc. Benefit of externalising ...