The Artima Developer Community
Sponsored Link

Java Buzz Forum
How to connect MySQL database from Java program with Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
How to connect MySQL database from Java program with Example Posted: Feb 2, 2013 6:24 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: How to connect MySQL database from Java program with Example
Feed Title: Java67
Feed URL:
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

When you start learning JDBC in Java, first program you want to execute is connect to database from Java and get some result back by executing some SELECT queries. In this Java program we will learn How to connect to MySQL database from Java program and execute query against it. I choose MySQL database because its free and and easy to install and setup. If you are using Netbeans IDE than you can connect MySQL Server directly from Netbeans, Which means in one window you could be writing Java code and other you can write SQL queries. Another advantage of using MySQL database is that it provides type 4 JDBC driver bundled in : mysql-connector-java-5.1.17-bin.jar which is easy to use. By the way if you are using Oracle database than you can check Java program to connect Oracle database, to connect and run SQL queries against Oracle db. This Java tutorial also explains some of the common error which comes while working in JDBC code e.g. during connection or reading results. In order to connect to MySQL database you need three things database URL, username and password and we are using default user root here, which is created during MySQL installation. By the way we have also used PreparedStatement for connection because it’s one of the JDBC best practice to use PreparedStatement for better performance and avoiding SQL Injection.
Read more »

Read: How to connect MySQL database from Java program with Example

Topic: Design Doesn’t Emerge from Code Previous Topic   Next Topic Topic: After silence on Java flaws, Oracle now says it cares

Sponsored Links


Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use