This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC Connection Problem

 
venu jayaram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,

I written one JDBC connection class. While running it's showing Exception.
i am using netbeans6.1 and jboss4.0.4 server. i added the driver also that is my-connector-java-5.1.

please help me to solve this problem




Exception are


init:
deps-module-jar:
deps-ear-jar:
deps-jar:
compile-single:
run-main:
com.mysql.jdbc.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2103)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at com.myapp.struts.Database.getConnection(Database.java:25)
at com.myapp.struts.Database.main(Database.java:36)
got connection
Caused by: java.net.UnknownHostException: mysql.local.com: mysql.local.com
at java.net.InetAddress.getAllByName0(InetAddress.java:1128)
at java.net.InetAddress.getAllByName0(InetAddress.java:1098)
at java.net.InetAddress.getAllByName(InetAddress.java:1061)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:243)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2026)
... 7 more
java.lang.NullPointerException
at com.myapp.struts.Database.main(Database.java:38)
BUILD SUCCESSFUL (total time: 20 seconds)
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have defined a JDBC URL that will try to connect the the DNS mysql.local.com. I'm guessing this doesn't exist. Shouldn't it be "localhost"?
 
venu jayaram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then please tell me what have to do, I want to interact with database using JDBC through Struts application.. please asap...


Thanks and Regards
Venu J
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the name of the host running MySQL? Change the database URL to use that host name (instead of "mysql.local.com"). If the MySQL database is running on the same host as your code, then use:

String URL = "jdbc:mysql://localhost:3306/venu";
 
venu jayaram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very Peter Johnson
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic