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); } } }
2 Antworten
+ 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
0
Thanks you i got it