| Author |
MySQL Connector J5 exe
|
dushantha Rathnayake
Ranch Hand
Joined: Feb 27, 2010
Posts: 100
|
|
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: 3670
|
|
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: 100
|
|
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: 3670
|
|
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: 100
|
|
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: 3670
|
|
|
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: 100
|
|
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: 3670
|
|
|
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: 100
|
|
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: 3670
|
|
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: 100
|
|
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: 3670
|
|
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
|
|
|