Create trigger mysql5 with java

Reply

Join Date: Apr 2007
Posts: 34
Reputation: onsir is an unknown quantity at this point 
Solved Threads: 1
onsir onsir is offline Offline
Light Poster

Create trigger mysql5 with java

 
0
  #1
Sep 3rd, 2007
Hi,
how to create trigger in mysql 5 with java.
i have code like this, but still error "
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$ CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`IF (' at line 1 "
thanks.


  1. SQL="";
  2. SQL="DELIMITER $$ "+
  3. "DROP TRIGGER `a1`.`xData` || "+
  4. "CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`" +
  5. "FOR EACH ROW BEGIN " +
  6. "IF (OLD.Name <> NEW.Name) THEN " +
  7. "INSERT INTO tlog (remark) VALUES ('EditData'); " +
  8. "END IF; " +
  9. "END;" +
  10. "$$" +
  11. "DELIMITER;";
  12. stmt=con.createStatement();
  13. rs=stmt.execute(SQL);
Last edited by onsir; Sep 3rd, 2007 at 5:15 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: wakydevil1 is an unknown quantity at this point 
Solved Threads: 0
wakydevil1 wakydevil1 is offline Offline
Newbie Poster
 
0
  #2
6 Days Ago
Originally Posted by onsir View Post
Hi,
how to create trigger in mysql 5 with java.
i have code like this, but still error "
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER $$ CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`IF (' at line 1 "
thanks.


  1. SQL="";
  2. SQL="DELIMITER $$ "+
  3. "DROP TRIGGER `a1`.`xData` || "+
  4. "CREATE TRIGGER `a1`.`xData` AFTER UPDATE ON `a1`.`tinfo`" +
  5. "FOR EACH ROW BEGIN " +
  6. "IF (OLD.Name <> NEW.Name) THEN " +
  7. "INSERT INTO tlog (remark) VALUES ('EditData'); " +
  8. "END IF; " +
  9. "END;" +
  10. "$$" +
  11. "DELIMITER;";
  12. stmt=con.createStatement();
  13. rs=stmt.execute(SQL);

I am having the same problem as well. There doesnt seem to be a lot of stuff on the internet regarding "triggers from Java"
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,433
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 507
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster
 
0
  #3
6 Days Ago
That is because it has nothing to do with Java itself. You're just sending a DDL statement to the database. Any difficulties with it would be specific to that database and the JDBC driver.
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC