Java Database Connectivity (JDBC) with MySQL

A simple code that finally brought cheer on our face..

Arif and me tried to connect to our mysql database using java.

We have done it and were able to connect using odbc driver with ms access. The experiment with mySql was preety difficult without an instructor but finally we made it.

 

We had to download this file (mysql-connector-odbc-5.1.6-win32) from mysql website for our machine.

Once the installation was complete, we went to control panel>administrative tools>odbc driver and picked it up.

 

Next task it to perform queries on our database

 

Hope everything goes fine

 

If you want to connect your mysql with a java program and have any issue, I can certainly help you now as am familiar with it now. J

 

Happy coding J

 

Filename db.java

import java.sql.*;

class db

{

 public static void main(String args[])

 {

 

                try

                {

         Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

         Connection con=DriverManager.getConnection("jdbc:odbc:data","root", "*****");

        

             if(!con.isClosed())

              System.out.println("Successfully connected");

 

 

                                               

                }

 

                catch(Exception e)

                {

                System.out.println("Exception"+e);

                }

 }

}

___

Love Marshall



 

Comments

Popular posts from this blog

I feel shame for Facebook Groups like "Growing INDIA, Growing Ourselves & making INDIA a better place to live in". They are capitalizing the Delhi Rape Case. Read how dirty is the Indian Politics where They ignore a Rape in Gujrat under Modi rule and Blame ladies like Sheila Dixing and Sonia for rapes. Stay Alert my Friends

Unwanted spam calls from +91-731-xxx-xxx