我在线程中遇到一个异常;“主要”;执行JDBC程序时发生java.sql.SQLException
这是我的密码我在线程中遇到一个异常;“主要”;执行JDBC程序时发生java.sql.SQLException,java,jdbc,Java,Jdbc,这是我的密码 import java.sql.*; import java.util.Scanner; class AccountDeletionApplication { public static void main(String[] args) throws ClassNotFoundException,SQLException { Scanner s=new Scanner(System.in); System.out.println("Ent
import java.sql.*;
import java.util.Scanner;
class AccountDeletionApplication
{
public static void main(String[] args) throws ClassNotFoundException,SQLException
{
Scanner s=new Scanner(System.in);
System.out.println("Enter the Acc no:");
int ano=s.nextInt();
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger");
Statement st=con.createStatement();
int n=st.executeUpdate("delete from ACCOUNT1 where ACCNO="+ano);
if(n==1)
System.out.println("account deleted succesfully");
else
System.out.println("account doesnt exist");
st.close();
con.close();
}
}
请发布整个堆栈跟踪,但很可能您的驱动程序不在类路径上。它不附带JVM。请下载它,并将其添加到类路径。在查询中使用字符串连接是一种不好的做法。这可能会导致sql注入…你应该准备语句..谷歌它..有很多例子:)请在你的问题中添加exception+stacktrace