Home / learning / Java / how to link java with MySQL (DBMS) database

how to link java with MySQL (DBMS) database



how to link java with MySQL (DBMS) database Publisher:
License:
Filesize:
Price:
Date added: July 24, 2013
Downloads:

Java is a programming language that helps in performing a particular task. DBMS is used to manage large amounts of data. Today most of the real time applications are a combination of Java and DBMS.

Oracle (SQL Plus) sometimes gets installed  in Windows 7 but when tried to access by entering the User Id and Password, denies the access. But it works when tried to connect using the SQL Command Prompt.

1)Download “ojdbc6.jar” file from the official Oracle website.

2)  Place it in “C:\Program Files\Java\jre6\lib\ext” directory. Sometimes this may need the permission of the Administrator to accept it.

3) Go to “Administrative Tools” by click on “Start” then go to “Control Panel” followed by “System Security” and then on “Administrative Tools”. Double click on ODBC from the right panel.

how to link java with mysql database 2

4)In the System DSN, click on “Add”. 

5)Select Oracle in XE from the options and click on “Finish”. If the DBMS used is MySQL then you need to select SQL Server from the options. Different applications have different Data Sources to be specified. So one should be careful while selecting the Data Source.

6)Specify the Data Source Name, TSN Name & UserId. Data Source Name is a sample data source used to connect to DBMS through Java. It can be given any name as desired. The description is just an additional explanation. It can be left blank. TNS Service Name is the name of the class in the tns file. The user Id is the Id used to connect to the server. Let the default applications be as it is and save it by click on “OK”.

7) The linking is completed. To check if the link is proper, Try out the below program by executing it using Command Prompt.

Replace the words Id and password with the Id and passport used to connect to the SQL server.

9)Compile it using “javac TestProgram.java”.

10)Run it using “java TestProgram”.

11)The output must display the following. 

how to link java with mysql database

If you had any questions let us know through comments.

About sai sandeep

Sandeep is the Founder and Author of this blog. He is a computer science student, works as an application and Web Based Programmer. He is a Young Entrepreneur a Web Designer and SEO expert.

One comment

  1. Thanks for sharing your thoughts about java.

Leave a Reply

Your email address will not be published. Required fields are marked *

*


6 + six =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Scroll To Top