import java.util.*;
import java.sql.*;
public class Jdbc {
public static void main(String j[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Id:-");
int id = sc.nextInt();
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "System", "Mohit");
String sql = "insert into st values(id)";
Statement stmt = conn.createStatement();
boolean res = stmt.execute(sql);
if (!res) {
System.out.println("Value Inserted");
} else {
System.out.println("Value Not Inserted");
}
} catch (Exception k) {
System.out.println("Exception is:-" + k);
}
}
}
在这里,在我的代码要插入数据库的价值,但它引发了我的异常,而在对帐单接口,我们不能通过值动态,但我们可以通过数值手动JDBC - ORA-00984:列在这里不允许
C:\Users\MOHIT\Desktop\PACK>java Jdbc
Enter Id:-0 0
Exception is:-java.sql.SQLException: ORA-00984: column not allowed here