wood burning stoves 2.0*
The moose likes JDBC and the fly likes MySQL Connector J5 exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL Connector J5 exe" Watch "MySQL Connector J5 exe" New topic
Author

MySQL Connector J5 exe

dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi,

I want to connect my java application in to MySQL data base.But I haven't that special connector.If anyone have that, please send it to me.I need it in exe format.please help me.
My email - Dushantha12@gmail.com.

Thank You.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

Hi Dushantha,

It's a jar file actually which you use to connect to DB. Get it from here.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi Vijitha,

I tried to run it.but actually it's did not run.That because I expect that application in an exe format. Please help me.

Thank you.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

dushantha Rathnayake wrote:I tried to run it.but actually it's did not run.

What you meant by "try to run it"?
That because I expect that application in an exe format. Please help me.

Don't get it, can you elaborate a little more?

BTW, how do you try to connect to DB, through JDBC or any other way?
dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi,

Now the Driver is ok.but the connection was not ok.

import java.sql.*;
public class Main {
public static void main(String[] args) throws Exception {
Connection connection = null;
try {
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost/low");
}
catch (Exception e) {
System.out.println(e);
}
}
}

general out in jcreator is :-

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Process completed.

Now what Iwant to do?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

Please UseCodeTags when posting code. You should provide username & password along with the URL in the "getConnection()" method. And are you able to connect to your MySQL server directly (i.e: from your command prompt or any GUI tool)?
dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi

I haven't any user name or password. Then I used this code.



but the result is same.

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

No, there should be a username/password to access the DB. Can you connect to DB directly as I asked in the previous reply?
dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi,

Connect to DB directly mean what? This is the code I only know to connect the db. Are there any other methods for connect DB? I have MySQL Workbench.I tried to create a password and user name.but there is a field, it is Pipe path.what is that?
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

I have MySQL Workbench

Well, MySQL Workbench is an ER modeling tool for MySQL, not a DB server. You can use it to for reverse engineering, SQL script generation and more.. You should have a MySQL server running, if not then download/install/configure it from here
dushantha Rathnayake
Ranch Hand

Joined: Feb 27, 2010
Posts: 103
Hi

Thank you very very much.....
I did it... I was connected the database and did my application functions.I did copy the connector (.jar file) in to,
And I did set CLASSPATH in environment variable section in Advance system settings.


Now it is ok.
Thank you again.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3815

dushantha Rathnayake wrote:I did it... I was connected the database and did my application functions.I did copy the connector (.jar file) in to, C:\Program Files\Java\jdk1.6.0_10\jre\lib\ext\mysql-connector-java-5.1.12-bin.jar

Don't put third party libraries inside the JDK/JRE installation folder. It's a bad practise...
 
 
subject: MySQL Connector J5 exe
 
Similar Threads
What type of MySQL
Why DB Visualizer?
How to create an installer for web application using install 4j
problem after installing mysql
JSP: Unable to connect to mysql in local drive [Solved]