File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Java DB Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java DB Connection" Watch "Java DB Connection" New topic

Java DB Connection

Betl Gokr

Joined: Feb 17, 2013
Posts: 3
Hi to GreenHorns ,

I am a newbie. I try to make a database connection and output its data to the console in NetBeans. I got the following output :

run: Usage: java JavaDBDemo <id> <Name>
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)

Why not it produces the database output ?

Thanks in advance.

Winston Gutkowski

Joined: Mar 17, 2011
Posts: 7492

Betl Gokr wrote:Why not it produces the database output ?

1. Is there any output to display?
2. Are you looking in the right place (ie, at the console window)?


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Ranjeet Deshmukh

Joined: Jan 18, 2013
Posts: 24

Have added the .jar file necessary for JDBC.
Along with that check DB is running or not.

Ranjeet Deshmukh

Joined: Jan 18, 2013
Posts: 24

Ranjeet Deshmukh wrote:if (args.length != 2) {
System.out.println("Usage: java JavaDBDemo <id> <Name>");

Remove or just comment this code.
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 459
Yes remove the code as pointed by Ranjeet. Probably you are passing one or no command line parameters.

Vinod Tiwari | Twitter
Wei Dai
Ranch Hand

Joined: Jun 22, 2005
Posts: 86
Betl Gokr wrote:

It should be "insert into employee values (?,?)"
I agree. Here's the link:
subject: Java DB Connection
Similar Threads
Runtime Error (ArrayIndexOutOfBoundsException)
Request Dispatcher problem
How to get ajax response in jsp page
java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbeddedDriver
not fetching values