• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 728
  • Last Modified:

java.sql.SQLException:General error

good days!

i faced this problem
java.sql.SQLException: General error,  message from server: "Access denied for user: '@%' to database 'cproduction'"       at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1651)       at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:889)       at com.mysql.jdbc.Connection.createNewIO(Connection.java:1566)       at com.mysql.jdbc.Connection.<init>(Connection.java:491)       at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)       at java.sql.DriverManager.getConnection(DriverManager.java:512)       at java.sql.DriverManager.getConnection(DriverManager.java:193)       at PickDraw.paint(PickDraw.java:210)       at sun.awt.RepaintArea.paint(RepaintArea.java:180)       at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260)       at java.awt.Component.dispatchEventImpl(Component.java:3586)       at java.awt.Container.dispatchEventImpl(Container.java:1582)       at java.awt.Component.dispatchEvent(Component.java:3367)       at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)       at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:191)       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)       at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

when i run an applet that need to query some data from database named mydb.

if i create a new account and use the new account id to acess the applet, then very things will run probably.
but if i logout from the system, and use the account id that created just now to acess the applet, this error will occur.

can somebody pls tell me what cause this error to occur and how to solve this problems...

thanks in advance.

rgds;
sw
0
sweewan
Asked:
sweewan
  • 7
  • 6
  • 2
1 Solution
 
SqueebeeCommented:
"Access denied for user: '@%' to database 'cproduction'"

Your applet passed '@%' as a username. This would not be a valid username and is not likely to be the username you wanted to pass in the first place. Your applet will need to pass a valid MySQL username and password for database access.
0
 
sweewanAuthor Commented:
Good Days!

Squeebee;

but i didn't set any password and username in order to acess MYSQL.

and if i created a new username for the system, every things run properly.
but if i logout from the system, and login again the username just created, this error will occur.

pls give some hints and guide.

thanks in advance.

rgds;
sw
0
 
SqueebeeCommented:
Well, something is being sent to the user, perhaps the '@%' string is being appended by your application. As for users not working after logging out, this could have to do with how the MySQL user is created. What is the code to create a new user?
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
sweewanAuthor Commented:
Squeebee;
0
 
sweewanAuthor Commented:
Squeebee;

the system will generate a username and password for user after a user finish all the pre-registration process.

i insert the username and password create by the system into db.

i use JSP and applet.

everythings run properly.. just the applet.

Thanks for ur suggestion and idea.

rgds;
sw
0
 
SqueebeeCommented:
Could it be that you are adding the user in a transaction that is never committed?
0
 
sweewanAuthor Commented:
Squeebee;

i try my system in my pc oredi.. every things oso run properly.

but when i deploy my system in other pc. this problems come out!

i oso dunno why this error occur.

Thanks.

rgds;
sw
0
 
SqueebeeCommented:
Hmm, did you install the JDBC driver properly on the second machine?
0
 
sweewanAuthor Commented:
good DAys!

squeebee;

yupe..

for the system, have few jsp file and 1 applet file.

for the jsp file, it run properly.. i mean insert record in db, no error occur.
but for the applet, when i  use applet to access db, that error occur oredi...

i check the table db in mysql, the column for host is % and the column for Db is test%, do i need to add another column in that table (host = % and Db = cprodcution)?
i check the db in mysql in the pc that run sucessfully, data inside the table db is same with the pc that can't  run properly...

Thanks for ur idea and Suggestion..

rgds;
sw
0
 
SqueebeeCommented:
Well, unfortunatly my Java knowledge is NULL, have you tried posting a request in the Java area of EE?
0
 
sweewanAuthor Commented:
Squeebee;

so.. u think should the java problems, and not the MYSQL's problems... right..?

 thanks for u suggestion..

rgds;
sw
0
 
SqueebeeCommented:
I would say yes based on the error message you recieved. Since it said the username passed was '@%', this would indicate to me that the Java app is passing an invalid username. This is of course based on my lack of knowledge of Java, so I am just going by the error message MySQL produced.
0
 
sobhunvCommented:
Hi guys..
In fact I had that Access denied problem in JSP pages...

Here r some ways I solved them:

1: install MYSQL ODBC 3.5 or more
2: Or find the jar file for java-mysql connector
     It is usually a jar file
     Unjar it and then place it in the JDK/lib directory..

It can work friends..
Cheers
sobhunv
0
 
sobhunvCommented:
Remember this should be done on the SERVER..
0
 
SqueebeeCommented:
Well good to know you found a solution.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now