• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is all your stack trace tells you? java.sql.SQLExceptions always come with at least some sort of reason.
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that's all i get!
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic