Java SE: Problem with MySql connection [message #754162] |
Tue, 01 November 2011 06:29 |
elGringo Messages: 3 Registered: October 2011 |
Junior Member |
|
|
Hi there!
I just got a problem, and i can't undetstand, how can it be.
My code:
try {
DriverManager.registerDriver((Driver) Class.forName("org.gjt.mm.mysql.Driver").newInstance());
Connection c = DriverManager.getConnection("jdbc:mysql://localhost/village", "root", "psw");
} catch (Exception e) {
e.printStackTrace();
}
Simplest code ever And it works great, when i run it in Eclipse 3.3.2, also it works great when I run it in command line "java.exe .....".
But it causes an exception in Eclipse 3.4.*, 3.5.*, and Indigo.
The exception is:
java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:943)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4113)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1308)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2336)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2369)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2153)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:792)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:381)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at main.main.main(main.java:22)
As you can see in source code upper, I use constant database URL, username and password, and it works in Eclipse 3.3.2 without any exception. I use the same database driver mysql-connector-java-5.1.18-bin.jar (I've try some other versions without any results)
All versions of eclipse I used "just out of box" - without any settings and customizing.
I just can't imagine where may be a problem. All i can say - something depends of Eclipse version.
Windows 7, 64bit; JVM and Eclipses - 32bit; (On 64bit JVM and eclipses i had the same problem)
I can't use new Eclipses because of it
Can somebody help me?
P.S. I'm not novice in Eclipse and Java, but i give up
P.P.S. I asked this question in JDT forum, but they sent me here.
[Updated on: Tue, 01 November 2011 07:06] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09210 seconds