Results 1 to 5 of 5
Thread: JDBC Problem
- 10-28-2010, 12:34 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 30
- Rep Power
- 0
JDBC Problem
Hi, I am Nitish Kumar. I have written the following program of jdbc:
package nitish.jdbc.first;
import java.sql.*;
import java.util.*;
public class JdbcEx1{
public static void main(String []s){
try{
Class c = Class.forName("oracle.jdbc.driver.OracleDriver");
Driver d = (Driver)c.newInstance();
Properties p = new Properties();
p.setProperty("user","scott");
p.setProperty("password","tiger");
Connection con = d.connect("jdbc:oracle:oci8@xe",p);
Statement st = con.createStatement();
String query = "insert into student_details values(1,'Nitish',5000);";
int recordsInserted = st.executeUpdate(query);
System.out.println("Record Inserted::"+ recordInserted);
}//try
catch(ClassNotFoundException cnfe){}
catch(InstantiationException ine){}
catch(IllegalAccessException iae){}
catch(SQLException sqle){}
}//main
}//class
The problem is that I am not getting the output. Means I am unable to connect to the database. When executing this program, it returns nothing. Instead, it should return an integer value. Even I changed the drivers also, but that also didn't help me. I am using Oracle 10g Enterprise Edition release 2. Please suggest me what to do.
Thank you
- 10-28-2010, 12:38 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Well, don't ignore exceptions. Add a printStackTrace to everyone of those catch blocks. How do you think to ever hear the siren when you've plugged your ears?
- 11-18-2010, 03:01 AM #3
Member
- Join Date
- Sep 2010
- Posts
- 30
- Rep Power
- 0
- 11-18-2010, 07:29 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
And actually placing something in the catch blocks would have told you that.
Edit: And, BTW, I have no idea what you mean by. If you mean some API designed to allow you to "ignore" exceptions in your coding and still be able to handle them, then it sounds like a simple crutch for someone not willing to do the work properly. If that's not what you mean, then I'm sorry I said that, but I thought it needed to be said, if that is what it is.Now, I always use behaviors to catch the exceptions.Last edited by masijade; 11-18-2010 at 07:40 AM.
- 11-18-2010, 06:25 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 30
- Rep Power
- 0
Similar Threads
-
Problem with Jdbc
By enjoybullife in forum Java ServletReplies: 4Last Post: 05-21-2010, 10:19 AM -
jdbc problem!!! pls help
By dilanka007 in forum New To JavaReplies: 1Last Post: 04-14-2010, 01:16 PM -
jdbc problem!!! pls help
By dilanka007 in forum New To JavaReplies: 5Last Post: 01-16-2010, 05:07 PM -
problem with jdbc in jsp
By nishant.4545 in forum JavaServer Pages (JSP) and JSTLReplies: 3Last Post: 08-29-2009, 01:31 PM -
JDBC problem
By peiceonly in forum Threads and SynchronizationReplies: 2Last Post: 08-03-2007, 01:42 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks