Go4Expert (http://www.go4expert.com/)
-   Database (http://www.go4expert.com/forums/database-forum/)
-   -   Need help with passing user defined variable in SQLJ (http://www.go4expert.com/forums/help-passing-user-defined-variable-sqlj-t27971/)

redkryptonite 7Mar2012 11:45

Need help with passing user defined variable in SQLJ
Hi i need to the user to input the variables ( "name" and "id" ) and by prepared statement they are passed to sql query. plz help ... and i need to know how to copy the output in ResultSet to a variable so it can me used else where..?


import java.sql.*;

public class File {
                public static void main(String s[])
                throws SQLException,Exception{
                Connection con = DriverManager.getConnection("jdbc:db2:SMART","",""  );
                String name;
                int id;
                System.out.println("Enter a the id: ");
                System.out.println("\n\nEnter the name: ");
                String query = "insert into db2admin.enduser values (?,?)";
                PreparedStatement ps=con.prepareStatement (query); 
                int i=ps.executeUpdate();
                System.out.println("record inserted count:"+i);


All times are GMT +5.5. The time now is 10:36.