My trigger code not working when I added it to my program, it's giving error and will not connect to database.
The following code I suspected to be causing the problem because, other insertion queries were working fine before I added the trigger query.
public class Connect_db {
Connection con;
public static Statement st = null;
public static Connection connectdb(){
try{
Class.forName("org.sqlite.JDBC");
Connection con= DriverManager.getConnection("jdbc:sqlite:eGiftCard.db","","");
st=con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS SetUpReward(Number INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, \n"
+ "min_Value DOUBLE (18, 2), \n"
+ "max_Value DOUBLE (18, 2), \n"
+ "reward_Point FLOAT, \n"
+ "card_Length INTEGER, \n"
+ "PayPal_Email TEXT, \n"
+ "Bank_Name TEXT, \n"
+ "Bank_Account TEXT)");
}
I am getting the following error.
java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database ()
at org.sqlite.DB.newSQLException(DB.java:374)
at org.sqlite.DB.throwex(DB.java:369)
at org.sqlite.NestedDB._exec(NestedDB.java:156)
at org.sqlite.Stmt.executeUpdate(Stmt.java:132)
at database_files.Connect_db.connectdb(Connect_db.java:56)
at view_controller.IGisftCardController.initialize(IGisftCardController.java:230
答案 0 :(得分:2)
CREATE TRIGGER IF NOT EXISTS eGiftCard.audit_log ...
INSERT INTO eGiftCard.ActivateAudit ...
数据库名称不是eGiftCard
,而是main
。
数据库名称不与文件名相同。
这里没有理由使用数据库名称;只需删除eGiftCard.
。
此外,缺少触发器END;
。