This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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: 8626

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