Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java DB Connection

 
Betl Gokr
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10427
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranjeet Deshmukh
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have added the .jar file necessary for JDBC.
Along with that check DB is running or not.
 
Ranjeet Deshmukh
Ranch Hand
Posts: 35
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 466
1
IntelliJ IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes remove the code as pointed by Ranjeet. Probably you are passing one or no command line parameters.
 
Wei Dai
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Betl Gokr wrote:


It should be "insert into employee values (?,?)"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic