944,204 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4839
  • Java RSS
Sep 3rd, 2007
0

Create trigger mysql5 with java

Expand 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.


Java Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
onsir is offline Offline
38 posts
since Apr 2007
Nov 18th, 2009
0
Re: Create trigger mysql5 with java
Click to Expand / Collapse  Quote originally posted by onsir ...
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.


Java Syntax (Toggle Plain Text)
  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"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wakydevil1 is offline Offline
2 posts
since Nov 2009
Nov 18th, 2009
0
Re: Create trigger mysql5 with java
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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Custom cell renderer rendering before all results returned from query
Next Thread in Java Forum Timeline: Build method for a tree





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC