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