If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Cannot connect to DB over network

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-09-03, 10:37
wbarbee wbarbee is offline
Registered User
 
Join Date: Nov 2003
Location: Raleigh, NC 27608 USA
Posts: 3
Question Cannot connect to DB over network

I have a JAVA application using a MySQL database. It worked as long as it was local.
When I try to use it on the network, I got errors.

(I have read the MySQL documentation several times but it just doesn't say anything useful.
Also, it seems oriented to a DB Administrator and not to programmers who have to use the db.
I have also looked at several forums but no match.)

Any help would be appreciated.

============

I installed MySQL and set it up with WinSQLAdmin for a Win 2000 Professional server.
I installed the MySQL Connection/J on the same server.

The JAVA application works fine with "localhost" usage on the server.

However, I have to implement the application on 6 or so PC's located on the network
and the Win2000 server will indeed be just a server.

So I installed MySQL and Connection/J on one of those PC's. Then I went into the
WinMySQLAdmin controls on that PC and changed the data folder from /mysql/data to
//Ihaserver/mysql/data. I changed the calling program to use the server data name.

The program appears to be trying to connect to the server across the network (it hesitated
for a few seconds where it was instantaneous connect before.

Then I get the error message: java.sql.SQLException: General error, message from server:
"Access denied for user: '@%' to database 'rescforsrs' "

I have set no passwords or users to the DB (that I know of).

I have tried some of the security things the documentation suggests, such as SHOW GRANTS.
I get an error message that there is no such command, even though I signed on as "root".

Help?

=============

//
// Define strings
//
private String SQLDBName;
private String SQLDBClass;

//
// Set data for connection
//
SQLDBClass = "org.gjt.mm.mysql.Driver";
SQLDBName = "jdbc:mysql://Ihaserver/RescForSrs";

NOTE - if "jdbc:mysql://localhost/rescforsrs" is used,
the program works OK.

//
// Perform connections
//
try {
Class.forName(SQLDBClass).newInstance();
}
catch (Exception e)
{
error display
}

try {
UserConn = DriverManager.getConnection(SQLDBName); <<<<<< This line causes the error
UserRead = UserConn.createStatement();
}
catch (Exception e)
{
error display
}
Reply With Quote
  #2 (permalink)  
Old 11-09-03, 12:01
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
Question

You need to say more than "you got errors." What exactly were those errors? When you are having connection problems over the network, you need to be able to diagnose... is the traffic actually reaching the server? Is the server refusing the connection or simply not understanding it? The MySQL server log usually gives clues. But you need to start by diagnosing the "pathology" of the problem, to begin with.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
  #3 (permalink)  
Old 11-09-03, 13:09
wbarbee wbarbee is offline
Registered User
 
Join Date: Nov 2003
Location: Raleigh, NC 27608 USA
Posts: 3
Question Error when connecting over network

The error message comes FROM the SERVER:
** This part from the Java Catch
java.sql.SQLException: General error, message from server:
** This part from the MySQL server
"Access denied for user: '@%' to database 'rescforsrs' "

In terms of more detail, I am stumped because the MySQL documentation is not very helpful on what commands to use to find out how the database is set up.

There is lots of data in the WinSQLAdmin display but which of it is useful?

I would be delighted to send more information if you can steer me in a direction to find it. For example, where is the log you mentioned?

Thanks...
Reply With Quote
  #4 (permalink)  
Old 11-11-03, 01:33
padm2016 padm2016 is offline
Registered User
 
Join Date: Oct 2003
Posts: 16
Hello,

Im pretty new to MySQL. But I guess this is the problem.

When you dont create any users and try to connect to the MySQL server remotely you will not be able to access all the databases. I guess you will have access to only the "test" database from the remote machine. You can check this by "show databases" in the remote machine after connecting to the server.

So if u want to have access to a particular database you created, you might want to create an user and assign him/her suitable persmissions to access the same.

Im sorry if Im wrong, but this might help.
Prasanna
Reply With Quote
  #5 (permalink)  
Old 11-20-03, 15:57
wbarbee wbarbee is offline
Registered User
 
Join Date: Nov 2003
Location: Raleigh, NC 27608 USA
Posts: 3
Answer to problem

The error message was coming from the MySQL server and said that I had not supplied a password.

Apparently you MUST have users and passwords to use MYSQL from a remote PC with the server.

I assigned users and passwords for the database.
I changed the DB paramters for the calls to:

SQLDBClass = "org.gjt.mm.mysql.Driver";
and
SQLDBName = "jdbc:mysql://IHASERVER/RescForSrs?user=JAVARFS&password=LUCY";

And the calls were OK as they were coded...
try {
Class.forName(SQLDBClass).newInstance();
}
catch (Exception e)
{
etc.
return;
}

try {
UserConn = DriverManager.getConnection(SQLDBName);
UserRead = UserConn.createStatement();
}
catch (Exception e)
{
etc.
return;
}

try {
ResultSet User_Result = UserRead.executeQuery("select UserPass, " +
etc.



AND IT WORKED!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On