File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Java DB Connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 8942

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)?


Bats fly at night, 'cause they aren't we. And if we tried, we'd hit a tree -- Ogden Nash (or should've been).
Articles by Winston can be found here
Ranjeet Deshmukh
Ranch Hand

Joined: Jan 18, 2013
Posts: 35

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

Ranjeet Deshmukh
Ranch Hand

Joined: Jan 18, 2013
Posts: 35

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: 466

Yes remove the code as pointed by Ranjeet. Probably you are passing one or no command line parameters.

Vinod Tiwari | Twitter | Shikshanirman | Guftgu
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
It's not a secret anymore!