question

Krv avatar image
Krv asked

this is the program for thread in sql, plz check is it right or not

import java.io.*; import java.sql.*; public class dk { public static void main(String[] args)throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader( System.in)); String rno,name,dept,mark; System.out.println("enter the value(rno,name,mark,dept)to be inserted"); rno=br.readLine(); name=br.readLine(); mark=br.readLine(); dept=br.readLine(); int r1no=Integer.parseInt(rno); int mark1=Integer.parseInt(mark); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:krmicro","scott","tiger"); PreparedStatement st=con.prepareStatement("insert into newtable values(?,?,?,?)"); st.setInt(1,r1no); st.setString(2,name); st.setInt(3,mark1); st.setString(4,dept); st.executeUpdate(); } catch(Exception e) { System.out.println(e); } } }
timetimestamptheory
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sp_lock avatar image sp_lock commented ·
I am not a programmer in anyway, but have to tested it? If so does it work or if not what is the error?
1 Like 1 ·
Fatherjack avatar image Fatherjack ♦♦ commented ·
@krv - please edit your question to make it clear what you would like assistance with or we will need to remove it from the forum.
0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.