Monday, March 20, 2017

Jdbc configurations in eclipse

 Usage of Mariadb java connector


#Download mariadb java connector mariadb-java-client-1.3.6.jar (exact name depends on the driver version) from https://downloads.mariadb.org/connector-java/
#Then include in eclipse under java build path --> libraries --> Add External Jar files and also include in tomcat web server under lib folder
#In servlet use the below code

<pre>
  //loading drivers for mysql
            Class.forName("org.mariadb.jdbc.Driver");

//creating connection with the database
          Connection  con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","dbuser","dbpasswd");
</pre>

 Usage of mysqldb java connector 


#Download mysql java connector mysql-connector-java-5.1.36-bin.jar (exact name depends on the driver version) from http://www.mysql.com/downloads/connector/j/
#Then include in eclipse under java build path --> libraries --> Add External Jar files and also include in tomcat web server under lib folder
#In servlet use the below code

<pre>
            //loading drivers for mysql
            Class.forName("com.mysql.jdbc.Driver");
 

//creating connection with the database
          Connection  con=DriverManager.getConnection("jdbc:mysql://localhost:3306/test","dbuser","dbpasswd");
</pre>