-1
這聽起來有點奇怪,但我想創建一個PreparedStatement
我有Statement
後。這是因爲我的項目差不多是50%,並且直到現在我還用Statement
的 。從語句創建PreparedStatement?
在我的數據庫類我有一個連接到mysql每當我需要使用MySQL服務器時的構造:
public class Database
{
private Statement m_statement = null;
private Connection m_connection = null;
private PreparedStatement m_prepared = null; // that one was added just now
private static final String ACCOUNTS_TABLE = "CheckingAccountsTable";
private static final String PERSONNEL_TABLE = "PersonnelTable";
// private static final String
public Database() throws ClassNotFoundException
{
try
{
Class.forName("com.mysql.jdbc.Driver");
this.m_connection = DriverManager.getConnection("jdbc:mysql://localhost","root","root");
this.m_statement = this.m_connection.createStatement();
}
catch (SQLException s)
{
System.out.println("SQL statement is not executed! 2!");
}
}
}
// from here I have something like 20 methods that are based on the Statement
改變一切將需要大量的時間,我沒有。所以,我的問題是:
我可以使用我創建的聲明與PreparedStatement
?或者根據Statement
創建PreparedStatement
?
謝謝
用預先聲明創建的聲明?你什麼意思? – 2012-08-08 16:36:44