File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException" Watch "SQLException" New topic
Author

SQLException

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i'm using java5, mySql 4.1 and my driver is mysql-connector-java-3.0.16-ga-bin.jar
i'm using eclipse 3.2 too
after testing my Jdbc class and get a green, i tried to test it from another computer that is in my home network
from mysql admin i granted everything to user root from my son's ip: 192.168.1.102

here's my code:


java amateur
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


when i run the jar from my son's pc, i get an SQLException i also tried to run, from dos:telnet pai 3306 but cant connect...(pai is my computer's name) what am i doing wrong? TiA

Please post the stack trace.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
C:\>java -jar X.jar
a come�ar...
Exception in thread "main" java.sql.SQLException: com.mysql.jdbc.Driver
at bd.JdbcAccess.getConnection(JdbcAccess.java:35)
at bd.Filhos.main(Filhos.java:23)
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
i just opened por 3306 from windows firewall and now telnet prints something, but when running the jar things are the same...
btw, i jared everything, driver included
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

That is all your stack trace tells you? java.sql.SQLExceptions always come with at least some sort of reason.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
that's all i get!
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
when i uncomment this line:
i get:
C:\>java -jar X.jar
a come�ar...
Exception in thread "main" java.lang.NullPointerException
at bd.Filhos.main(Filhos.java:37)
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
just in case, i also did:
mysql> grant all privileges on *.* to root@192.168.1.102
-> ;
Query OK, 0 rows affected (0.00 sec)
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133

i tried to test it from another computer that is in my home network
from mysql admin i granted everything to user root from my son's ip: 192.168.1.102

String url = "jdbc:mysql://pai/" + nomeBaseDados + "?user=root@192.168.1.102&password=xxx";

(pai is my computer's name)



is pai running the mySql? if so, try the ip address.

add the port 3306

String url = "jdbc:mysql://pai:3306/" + nomeBaseDados + "?user=root@192.168.1.102&password=xxx";

maybe even try passing the connection params

[ August 17, 2006: Message edited by: graham king ]

write, revise, re-write, revise, again...<br />write, revise, re-write, revise, again...
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
thanks for the sugestion
i tried that and a variety of other possible combinations

somehow i've the felling that, from my son's pc, connection is never established

mi idea is that i have my url wrong...

at this moment i have it like this:
String url = "jdbc:mysql://192.168.1.101/" + nomeBaseDados + "?user=root&password=abc";
and if i run the class from my pc(where mySql is), it prints ok:

a come�ar...
inside try block
inside finally block 1
inside finally block 2

but from my son's, not at all

dont know what to do
[ August 17, 2006: Message edited by: miguel lisboa ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException