wood burning stoves 2.0*
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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Java DB Connection" Watch "Java DB Connection" New topic
Author

Java DB Connection

Betl Gokr
Greenhorn

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
Bartender

Joined: Mar 17, 2011
Posts: 7711
    
  20

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

Winston


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
Ranch Hand

Joined: Jan 18, 2013
Posts: 32

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


~R@njeet.
Ranjeet Deshmukh
Ranch Hand

Joined: Jan 18, 2013
Posts: 32

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



Remove or just comment this code.
Vinod Tiwari
Ranch Hand

Joined: Feb 06, 2008
Posts: 459
    
    1
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 (?,?)"
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java DB Connection