0

Jdbc error

import java.sql.*; import java.util.Scanner; class jd{ public static void main(String args[]) throws Exception { ; try{ Scanner sc=new Scanner(System.in); System.out.println("enter name:"); String name=sc.next(); System.out.println("enter location:"); String loc=sc.next(); Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/std_info","root",""); PreparedStatement ps=conn.PreparedStatement("insert into std_record value(?,?)"); ps.setString(1,name); ps.setString(2,loc); ps.executeUpdate(); System.out.print("execute successfully.......!"); conn.close(); } catch(Exception e){ System.out.println(e); } } }

26th Mar 2021, 2:48 AM
santhosh Kumar
santhosh Kumar - avatar
2 ответов
+ 1
// comment that semicolon after main() { // ; // conn.prepareStatement() method is lowercase, and there is not -ed //PreparedStatement ps = conn.PreparedStatement( PreparedStatement ps = conn.prepareStatement( "insert into std_record value(?,?)"); there might be other errors
26th Mar 2021, 11:59 AM
zemiak
0
Thanks you i got it
26th Mar 2021, 12:17 PM
santhosh Kumar
santhosh Kumar - avatar