Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Java SE: Problem with MySql connection(Problem depends of Eclipse version (!!!))
Java SE: Problem with MySql connection [message #754162] Tue, 01 November 2011 06:29 Go to next message
elGringo  is currently offline elGringo Friend
Messages: 3
Registered: October 2011
Junior Member
Hi there!

I just got a problem, and i can't undetstand, how can it be. Sad

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 Smile 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 Sad
Can somebody help me?
P.S. I'm not novice in Eclipse and Java, but i give up Smile
P.P.S. I asked this question in JDT forum, but they sent me here. Smile

[Updated on: Tue, 01 November 2011 07:06]

Report message to a moderator

Re: Java SE: Problem with MySql connection [message #754751 is a reply to message #754162] Fri, 04 November 2011 08:01 Go to previous messageGo to next message
HainaSoft  is currently offline HainaSoft Friend
Messages: 18
Registered: October 2011
Junior Member
What a puzzle! Have you tried to clean and rebuild the project? Sometimes clean up a project may solve the problem.
Re: Java SE: Problem with MySql connection [message #754929 is a reply to message #754751] Sat, 05 November 2011 09:40 Go to previous message
elGringo  is currently offline elGringo Friend
Messages: 3
Registered: October 2011
Junior Member
HainaSoft wrote on Fri, 04 November 2011 04:01
What a puzzle! Have you tried to clean and rebuild the project? Sometimes clean up a project may solve the problem.

I've just try "Clean project", but it doesn't help me... Sad

Does somebody have or had the same problem at all?

[Updated on: Sat, 05 November 2011 16:07]

Report message to a moderator

Previous Topic:No repository found
Next Topic:UnsupportedOperationException
Goto Forum:
  


Current Time: Tue Apr 23 09:16:49 GMT 2024

Powered by FUDForum. Page generated in 0.07942 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top