package jdbcDemo;
import java.sql.*;
public class PreparedStatement {
public static void main(String[] args){
// using SQL to insert,edit,delete information from a database
Connection myConn =null;
PreparedStatement myStmt=null;
ResultSet myRs=null;
try{
// 1.make a connection to database
myConn= DriverManager.getConnection("jdbc:mysql://localhost:3306/shopping_cart","root","1578");
//2.create a statement
myStmt= myConn.prepareStatement("SELECT * FROM shopping_cart.customers where total_cost>? and items_number>?");
//3.set parameters
myStmt.setDouble(1,2);
myStmt.setDouble(2,40);
myRs=myStmt.executeQuery();
}
catch(Exception exc){
exc.printStackTrace();
}
}
へのjava.sql.PreparedStatementから変換することはできません、私はプリペアドステートメントを作成しようとしているが、「型の不一致を持っています:のjava.sql.PreparedStatementから変換することはできませんto jdbcDemo。PreparedStatement "を選択します。私はそれをgoogled、答えのほとんどは、java.sql。*をインポートする必要があると私は言ったが、まだ答えを得たと言う。型の不一致:ステップ2ではjdbcDemo.PreparedStatement
と
変更自分のクラスの名前または交換は、それは' 'java.sql.PreparedStatement' import'をシャドウ。または、完全修飾クラス名 'java.sql.PreparedStatement myStmt = null;'を使用してください。 –