AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help for a newbee please!

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
Chris Hatton
Guest





PostPosted: Wed Dec 15, 2004 2:10 pm    Post subject: Help for a newbee please! Reply 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?

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





PostPosted: Wed Dec 15, 2004 2:37 pm    Post subject: Re: Help for a newbee please! Reply with quote



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





PostPosted: Wed Dec 15, 2004 3:18 pm    Post subject: Re: Help for a newbee please! Reply with quote



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





PostPosted: Wed Dec 15, 2004 4:46 pm    Post subject: Re: Help for a newbee please! Reply with quote

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





PostPosted: Wed Dec 15, 2004 8:00 pm    Post subject: Re: Help for a newbee please! Reply with quote

I think the problem is probably with access to the site.

Back to top
Chris Hatton
Guest





PostPosted: Thu Dec 16, 2004 1:12 pm    Post subject: Re: Help for a newbee please! Reply with quote

[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
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.