Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 Java and Databases

View previous topic View next topic Go down 
AuthorMessage
theresonlyoneash
Member
Member
theresonlyoneash

Posts : 2
Join date : 2011-04-16

Java and Databases Empty
PostSubject: Java and Databases   Java and Databases EmptySat Apr 16, 2011 9:00 pm

I have a started a task on using java to link it to a mysql database, does anyone know any good sites where I can get rich detail to break down how it is done?
Back to top Go down
Wishes
Member
Member
Wishes

Posts : 9
Join date : 2011-04-16

Java and Databases Empty
PostSubject: Re: Java and Databases   Java and Databases EmptySat Apr 16, 2011 9:07 pm

How to connect to a MySQL database using JDBC?

This example connects to a MySQL database using the MM JDBC driver for MySQL. You need to have an account in MySQL database to run this example. To create an account, you can connect to MySQL database on your platform as root, and run the following command:
mysql> GRANT ALL PRIVILEGES ON *.* TO username@localhost
IDENTIFIED BY 'password' WITH GRANT OPTION;


Connection connection = null;
try {
// Load the JDBC driver
String driverName = "org.gjt.mm.mysql.Driver"; // MySQL MM JDBC driver
Class.forName(driverName);

// Create a connection to the database
String serverName = "localhost";
String mydatabase = "mydatabase";
String url = "jdbc:mysql://" + serverName + "/" + mydatabase; // a JDBC url
String username = "username";
String password = "password";
connection = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
// Could not find the database driver
} catch (SQLException e) {
// Could not connect to the database
}

is this what you were looking for?
Back to top Go down
Knowledge
Member
Member
Knowledge

Posts : 21
Join date : 2011-03-09

Java and Databases Empty
PostSubject: Re: Java and Databases   Java and Databases EmptySat Apr 16, 2011 9:09 pm

theresonlyoneash wrote:
I have a started a task on using java to link it to a mysql database, does anyone know any good sites where I can get rich detail to break down how it is done?

You could try this website. http://dev.mysql.com/usingmysql/java/
Back to top Go down
theresonlyoneash
Member
Member
theresonlyoneash

Posts : 2
Join date : 2011-04-16

Java and Databases Empty
PostSubject: Astonished   Java and Databases EmptySat Apr 16, 2011 9:28 pm

Im new to this site and got really fast responses, thanks and yes it is what im looking for, i will try it out
Back to top Go down
Sponsored content




Java and Databases Empty
PostSubject: Re: Java and Databases   Java and Databases Empty

Back to top Go down
 

Java and Databases

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» question regarding databases and RoR
» New to Ruby from Java
» Ruby Java Bridge
» [java] Share a variable?
» Bad Little Java Thinker - Recaptcha Faking

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: Java and Databases Edit-trash Useless :: Trash-