Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / January 2004

Tip: Looking for answers? Try searching our database.

MySQL Access Denied to user???!#%!%#!

Thread view: 
DeZZaN - 29 Jan 2004 18:35 GMT
Please help!!!

I have a problem when I try to connect to mysql server located on the
host
named zeus thru the jdbc: mysql-connector-java!!!
(what is even more weird is that I have no problems connecting and
doing
whatever I want thru mysql client using the connection string: mysql
-h zeus -u dgjorgjevik kompanija)??????

It keeps giving me this error message:

Connection string: jdbc:mysql://zeus:3306/kompanija&user=dgjorgjevik&password=
Error: 1044 -> S1000
Message: General error,  message from server: "Access denied for user:
'@%' to database 'kompanija&user=dgjorgjevik&password='"
java.lang.NullPointerException
       at DBPrebaruvanje.DBConnection.getResultset(DBConnection.java:76)
       at DBPrebaruvanje.DBConnection.getResultset(DBConnection.java:84)
       at switchboardApp.EmployeeForm.initComponents(EmployeeForm.java:53)
       at switchboardApp.EmployeeForm.<init>(EmployeeForm.java:24)
       at switchboardApp.SwitchboardApp.<init>(SwitchboardApp.java:42)
       at switchboardApp.SwitchboardApp.main(SwitchboardApp.java:235)

And the code to produce this is:
conn = new DBConnection("kompanija", "dgjorgjevik", "",
DBConnection.MYSQL, "zeus");

//constructor for DBConnection class
public DBConnection(String DBN, String user, String pass, int
serverType, String host) {
       String strClassName;
       String strConnection;
       DBName = DBN;
       username = user;
       password = pass;
       
       if (serverType == ODBC) {
           strClassName = "sun.jdbc.odbc.JdbcOdbcDriver";
           strConnection = "jdbc:odbc:" + DBName;
       } else if (serverType == MYSQL) {
           strClassName = "com.mysql.jdbc.Driver";
           strConnection = "jdbc:mysql://" + host + ":3306/" + DBName
+ "&user=" + user + "&password=" + pass;
       } else {
           strClassName = "";
           strConnection = "";
       }
       try {
           Class.forName(strClassName);
       } catch (ClassNotFoundException e) {
           System.out.println("Couldn't find class!");
           e.printStackTrace();
       }
       try {
           if (serverType == ODBC) {
               conn = DriverManager.getConnection(strConnection,
username, password);
           } else if (serverType == MYSQL) {
               conn = DriverManager.getConnection(strConnection);
           }
       } catch (SQLException e) {
           System.out.println("Connection string: " + strConnection);
           System.out.println("Error: " + e.getErrorCode() + " -> " +
e.getSQLState());
           System.out.println("Message: " + e.getMessage());
       }
   }
David Harper - 29 Jan 2004 18:47 GMT
> Please help!!!
>
[quoted text clipped - 19 lines]
>         at switchboardApp.SwitchboardApp.<init>(SwitchboardApp.java:42)
>         at switchboardApp.SwitchboardApp.main(SwitchboardApp.java:235)
[ SNIP ]

We can help you better if you tell us some important details:

[1] What operating system are you running your server on?

[2] Are you running the mysql command-line clieent on the same machine
  as your MySQL server?

[3] Are you running your Java client on the same machine as your MySQL
  server?

[4] Are your mysql command-line client and your Java client running on
  the same machine?

David Harper
Cambridge, England
nioTo - 29 Jan 2004 19:38 GMT
Le 29/01/2004 19:35, DeZZaN a &eacute;crit :

> Please help!!!

Ok,

> It keeps giving me this error message:
>
> Connection string: jdbc:mysql://zeus:3306/kompanija&user=dgjorgjevik&password=
> Error: 1044 -> S1000
> Message: General error,  message from server: "Access denied for user:
> '@%' to database 'kompanija&user=dgjorgjevik&password='"

well, it doesn't read correctly the parameters, so (re-)read  the documentation
and you'll find :
http://www.mysql.com/documentation/connector-j/index.html#id2801986
>>>Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=monty&password=greatsqldb");

So, know try, in DBConnection :
    strConnection = "jdbc:mysql://" + host + ":3306/" + DBName
+ "?user=" + user + "&password=" + pass;
  ^^^
instead of :

>             strConnection = "jdbc:mysql://" + host + ":3306/" + DBName
> + "&user=" + user + "&password=" + pass;
DeZZaN - 30 Jan 2004 09:07 GMT
> Le 29/01/2004 19:35, DeZZaN a &eacute;crit :
>
[quoted text clipped - 22 lines]
> >             strConnection = "jdbc:mysql://" + host + ":3306/" + DBName
> > + "&user=" + user + "&password=" + pass;

Thanks a lot, this really helped and finally everything is OK!

Dejan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.