Coonection Problem in java (oracle)

Posted on 2009-07-08
Last Modified: 2013-11-23
Hi ,

i am using 2 java class ,

1st class  program

DBConn dba=new DBConn();
Connection con=null;

String query="insert into gen_info(EMP_NAME,EMP_ID,TECH) "+ "values(?,?,?)";
//Statement st=con.createStatement();
PreparedStatement psmnt=null;

boolean s = psmnt.execute();
if (s)
      System.out.println("Succesfully inserted");
      System.out.println("Cant Insert");

its call DBConn class , thats have connection coding
                              // System.out.println("Failed to load isqlPlus driver.");
                              //DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());

                        catch (Exception ae) {

                        try {

                              String url1 = System.getProperty("JDBC_URL");
                              if (url1 != null)
                                    url = url1;
                              PreparedStatement psmnt=null;
                              con = DriverManager.getConnection(url,
                                          "system", "tspl");
                              psmnt = con.prepareStatement(query);
                        } catch (Exception e) {
                  } catch (Exception e) {

afterfinish this its return back to 1st  preparestmaent is null its throw the null pointer excetion
kindly help me to reslove this !!

Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 24807142

Did you remember to make objects of the connections? ( = new ...())
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 24810959
I am using 2 class sirtam so preparestatement variable is null when the nrturn back excute the query .
LVL 20

Accepted Solution

Sathish David  Kumar N earned 0 total points
ID: 24924004
prepareStament is local to that class so thats value is null so its say null ponter exception

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java imports not found 4 49
Notify sent to other threads in Java 9 42
Html split(text) 2 28
Java List 4 35
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question