urgent

1 view
Skip to first unread message

bankim pandya

unread,
Apr 8, 2010, 12:25:09 PM4/8/10
to open-traini...@googlegroups.com
this is my .java file i can't understand y the execution is not goin beyond the line int success=rs.executeUpdate(sql); please help


import java.lang.*;
import java.sql.*;
 class oraclejava {
    public static void main(String args[])throws SQLException,ClassNotFoundException
{
    /*String cust = "00005";
        String sname = "PKEL";
        String fname = "pATWA KINARIWALA";
        String pass = "hshshhshs";
        String role = "PERMENANT";
        String add1 = "AJWA ROAD";
        String add2 = "WAGHODIYA";
        String add3 = "SARDAR";
        String city = "VADODARA";
        String zip = "390016";
        String tcode = "02";
        String name1 = "BANKIM";
        String contact1 = "9809807654";
        String contact2 = "9809107654";
        String email1 ="BANKIM....@GMAIL.COM";
        String name2 = "BAKIMPANDYA";
        String contact3 = "9801207654";
        String contact4="9809802354";
        String email2= "BANKIM...@GMAIL.COM";*/
        String city = "VADODARA";
String name1 = "BAKIMPANDYA";
        try {   
   
    Class.forName("oracle.jdbc.driver.OracleDriver");
   
 Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:PKEL", "SYS AS SYSDBA", "bankim");

    Statement st=con.createStatement();
    String sql1="INSERT INTO SYSTEM.STUDENT VALUES('" + name1 + "','" + city + "')";
  //String sql="INSERT INTO CUSTOMER_MASTER VALUES('" + cust + "','" + sname + "','" + fname + "','" + pass + "','" + role + "','" + add1 + "','" + add2 + "','" + add3 + "','" + city + "','" + zip + "','" + tcode + "','" + name1 + "','" + contact1 + "','" + contact2 + "','" + email1 + "','" + name2 + "','" + contact3 + "','" + contact4 + "','" + email2 + "')";
                                   
        int success=st.executeUpdate(sql1);                                                   
                                                                System.out.println("hEllppppppppppppqq");
                                   if(success>0)
                                   {
                                       System.out.println("Data updated successfully");
                                   }
                                   else
                                   {
                                       System.out.println("Data not updated successfully");
                                   }
                                   con.close();
                                    }
                                                                catch(Exception e)
                                                                {
                                                                }
               
                                   
}
}


output
Starting application oraclejava
Interactive Session Ended

Kinnaree Patel

unread,
Apr 9, 2010, 1:30:45 AM4/9/10
to open-traini...@googlegroups.com
Hi Bankim,

It is giving any errors? What does it show up in logs?


--
You received this message because you are subscribed to the Google
Groups "open-training-community" group.
To post to this group, send email to
open-traini...@googlegroups.com
To unsubscribe from this group, send email to
open-training-com...@googlegroups.com
For more options, visit this group at
http://groups.google.co.in/group/open-training-community?hl=en-GB

bankim pandya

unread,
Apr 9, 2010, 1:55:17 AM4/9/10
to open-traini...@googlegroups.com
it isn't showing nething in log but may be i think the values that are being inserted may not be available inside the try block so i must declare the variables above main or inside try block...

Abhilash

unread,
Apr 9, 2010, 4:30:36 AM4/9/10
to open-traini...@googlegroups.com
Declare it above the try block and see!

On Fri, Apr 9, 2010 at 1:55 PM, Abhilash <pillaia...@gmail.com> wrote:
How will you get the value of "int success"? does the insert query returns you back anyting!!

Abhilash

unread,
Apr 9, 2010, 4:25:30 AM4/9/10
to open-traini...@googlegroups.com
How will you get the value of "int success"? does the insert query returns you back anyting!!

On Fri, Apr 9, 2010 at 11:25 AM, bankim pandya <bankim.p...@gmail.com> wrote:

silvans solanki

unread,
Apr 10, 2010, 11:09:41 AM4/10/10
to open-traini...@googlegroups.com
hi bankim try to use PreparedStatement instead of Statement...
Reply all
Reply to author
Forward
0 new messages