SLA
SLA

Reputation: 363

Connecting to a MySQL database

I have created a MySQL database. I am building a GUI in java. How can I connect this Java software to the database?

Upvotes: 1

Views: 668

Answers (5)

Andy
Andy

Reputation: 3682

I've already added one answer - asking a question but the comments/reply's I got seem to be a bit off topic and now I've commented back asking for the answer to my original question no one seems to be answering (Have a look for your self - see what I mean)

So, the orignal question :: The only thing I want to know;

Do the users of my software I made using JDBC have to do anything special regarding JDBC, or is just me who needs to have JDBC while writting the program?

PS Sorry if I'm a bit pushy or doing things that your not supposed to do - I'm new to this community!

Upvotes: 0

Andy
Andy

Reputation: 3682

this post has helped me quite alot! I'm quite 'disapointed' and 'suprised' I suppose that Java doesn't have the fuctionatly of connected to online databases built in. One thing that would make it better, and please tell me the followings true: the fact that users of my software don't have to do anything special like install any drivers?

Upvotes: 0

Maurice Perry
Maurice Perry

Reputation: 32831

First, you need to add the mysql jdbc driver jar to your project, then you would create a connection as follows:

String url = "jdbc:mysql://yourhost:port/dbname";
Class.forName ("com.mysql.jdbc.Driver"); // to load the driver
Connection conn = DriverManager.getConnection (url, userName, password);

Here yourhost is the name or ip address of the server, port is the port number to which the mysql server is bound, dbname is the name of your database.

Upvotes: 2

amra
amra

Reputation: 16875

Start using JDBC, it's best for start. Take a look on some tutorials

Upvotes: 0

hhafez
hhafez

Reputation: 39750

using any of the miriad of Java/SQL API, so you can perform normal SQL queries. JDBC is a start

Upvotes: 0

Related Questions