 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Chris Hatton Guest
|
Posted: Wed Dec 15, 2004 2:10 pm Post subject: Help for a newbee please! |
|
|
I'm having problems trying to connect to a remote mySQL db. I have have
got this working on localhost but can get it to work for my website db.
Can anyone point out problems with the code or general problems I shoudl
be looking out for?
protected Connection getConnection () throws Exception {
String url = "";
String userName = "";
String password = "";
try {
url = "jdbc:mysql://www.tattooplace.co.uk/tattoop_chatusers";
userName = "*******";
password = "*******";
Connection con = DriverManager.getConnection(url, userName,
password);
System.out.println("Connection established to " + url + "...");
return con;
} catch ( java.sql.SQLException e ) {
System.out.println("Connection couldn't be established to " + url);
throw ( e );
}
}
|
|
| Back to top |
|
 |
kaeli Guest
|
Posted: Wed Dec 15, 2004 2:37 pm Post subject: Re: Help for a newbee please! |
|
|
In article <41c045e2$1 (AT) nntphost (DOT) cis.strath.ac.uk>,
[email]chrishatton (AT) blueyonder (DOT) co.uk[/email] enlightened us with...
| Quote: | I'm having problems trying to connect to a remote mySQL db. I have have
got this working on localhost but can get it to work for my website db.
Can anyone point out problems with the code or general problems I shoudl
be looking out for?
|
What's the error you're getting?
To see better, more detailed error messages, print out e.getMessage() and do
a e.printStackTrace() here, instead of just rethrowing the error.
For a website, you may need to grab the output stream instead of using
System.out. How to do that depends a bit on whether you're using JSP/beans
(you'd need to pass JSPWriter response in or set a property in the bean or
throw it to a custom error page) or a servlet (you can just write to
response).
| Quote: | } catch ( java.sql.SQLException e ) {
System.out.println("Connection couldn't be established to " + url);
throw ( e );
}
}
|
--
--
~kaeli~
If at first you don't succeed, skydiving is not for you.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
|
|
| Back to top |
|
 |
Chris Hatton Guest
|
Posted: Wed Dec 15, 2004 3:18 pm Post subject: Re: Help for a newbee please! |
|
|
kaeli wrote:
| Quote: | In article <41c045e2$1 (AT) nntphost (DOT) cis.strath.ac.uk>,
[email]chrishatton (AT) blueyonder (DOT) co.uk[/email] enlightened us with...
I'm having problems trying to connect to a remote mySQL db. I have have
got this working on localhost but can get it to work for my website db.
Can anyone point out problems with the code or general problems I shoudl
be looking out for?
What's the error you're getting?
To see better, more detailed error messages, print out e.getMessage() and do
a e.printStackTrace() here, instead of just rethrowing the error.
For a website, you may need to grab the output stream instead of using
System.out. How to do that depends a bit on whether you're using JSP/beans
(you'd need to pass JSPWriter response in or set a property in the bean or
throw it to a custom error page) or a servlet (you can just write to
response).
} catch ( java.sql.SQLException e ) {
System.out.println("Connection couldn't be established to " + url);
throw ( e );
}
}
This is the error I am getting but it doesn't mean much to me: |
MySQL Driver Found
Connection couldn't be established to
jdbc:mysql://www.tattooplace.co.uk/tattoop
_chatusers
Invalid authorization specification message from server: "Access denied
for user
: 'tattoop_chris (AT) 82-40-66-187 (DOT) cable.ubr09.uddi.blueyonder.co.uk' (Using
password
: YES)"
java.sql.SQLException: Invalid authorization specification message from
server:
"Access denied for user:
'tattoop_chris (AT) 82-40-66-187 (DOT) cable.ubr09.uddi.blueyonder
..co.uk' (Using password: YES)"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1906)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:954)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1786)
at com.mysql.jdbc.Connection.<init>(Connection.java:450)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:411)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestMySQL.getConnection(TestMySQL.java:71)
at TestMySQL.test(TestMySQL.java:20)
at Driver.main(Driver.java:7)
Press any key to continue...
|
|
| Back to top |
|
 |
Chris Hatton Guest
|
Posted: Wed Dec 15, 2004 4:46 pm Post subject: Re: Help for a newbee please! |
|
|
kaeli wrote:
| Quote: | In article <41c045e2$1 (AT) nntphost (DOT) cis.strath.ac.uk>,
[email]chrishatton (AT) blueyonder (DOT) co.uk[/email] enlightened us with...
I'm having problems trying to connect to a remote mySQL db. I have have
got this working on localhost but can get it to work for my website db.
Can anyone point out problems with the code or general problems I shoudl
be looking out for?
What's the error you're getting?
To see better, more detailed error messages, print out e.getMessage() and do
a e.printStackTrace() here, instead of just rethrowing the error.
For a website, you may need to grab the output stream instead of using
System.out. How to do that depends a bit on whether you're using JSP/beans
(you'd need to pass JSPWriter response in or set a property in the bean or
throw it to a custom error page) or a servlet (you can just write to
response).
} catch ( java.sql.SQLException e ) {
System.out.println("Connection couldn't be established to " + url);
throw ( e );
}
}
This is the error I am getting but it doesn't mean much to me: |
MySQL Driver Found
Connection couldn't be established to
jdbc:mysql://www.tattooplace.co.uk/tattoop
_chatusers
Invalid authorization specification message from server: "Access denied
for user
: 'tattoop_chris (AT) 82-40-66-187 (DOT) cable.ubr09.uddi.**ueyonder.co.uk' (Using
password
: YES)"
java.sql.SQLException: Invalid authorization specification message from
server:
"Access denied for user:
'tattoop_chris (AT) 82-40-66-187 (DOT) cable.ubr09.uddi.**ueyonder
..co.uk' (Using password: YES)"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1906)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:954)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1786)
at com.mysql.jdbc.Connection.<init>(Connection.java:450)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:411)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestMySQL.getConnection(TestMySQL.java:71)
at TestMySQL.test(TestMySQL.java:20)
at Driver.main(Driver.java:7)
Press any key to continue...
|
|
| Back to top |
|
 |
klynn47@comcast.net Guest
|
Posted: Wed Dec 15, 2004 8:00 pm Post subject: Re: Help for a newbee please! |
|
|
I think the problem is probably with access to the site.
|
|
| Back to top |
|
 |
Chris Hatton Guest
|
Posted: Thu Dec 16, 2004 1:12 pm Post subject: Re: Help for a newbee please! |
|
|
[email]klynn47 (AT) comcast (DOT) net[/email] wrote:
| Quote: | I think the problem is probably with access to the site.
Got it!!! I never set my access hosts properly, in fact I didn't know |
what they where until now
thank god for that, I can start to code again now.
Cheers
Chris
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|