Note that an IntelliJ IDEA data source is not running in the same JVM that 
your project is running in. The data source is independent of your project 
code, and has no awareness of it.

I guess you'd have to compile your Trigger class, bundle it into a jar, and 
add that jar to the data source config's driver files section.




On Tuesday, 14 June 2016 05:35:17 UTC+2, Chronpwn wrote:
>
> I am using IntelliJ IDEA as my IDE, and they have an option where you can 
> specify the Driver URL. I tested this connection and am able to connect to 
> the database, but when I add a new trigger:
>
> public class VoteInsertTrigger extends TriggerAdapter {
>
>     @Override
>     public void fire(Connection conn, ResultSet oldRow, ResultSet newRow) 
> throws SQLException {
>         Statement statement = conn.createStatement();
>
>         boolean vote = newRow.getBoolean(newRow.findColumn("vote"));
>         int deckId = newRow.getInt("deck_id");
>         int value = vote ? 1 : -1;
>
>         String sql = "UPDATE DECKS SET DECKS.RATING=DECKS.RATING + %d WHERE 
> DECKS.ID=%d";
>         sql = String.format(sql, value, deckId);
>
>         statement.executeUpdate(sql);
>     }
> }
>
>
> With the command:
>
> CREATE TRIGGER vote_insert
> BEFORE INSERT
> ON USERS_VOTES
> FOR EACH ROW
> CALL "com.chronpwn.chronpwn.data.VoteInsertTrigger"
>
>
> it fails with: "cause: "org.h2.message.DbException: Class 
> ""VoteInsertTrigger"" not found"
>
> I rebuilt my entire project which puts the VoteInsertTrigger class in my 
> classpath.
>
> When you mention "The trigger class must be available in the classpath of 
> the database engine," my entire project + the H2 jar are on the 
> classpath, so I would appreciate some insight on why this is happening. 
> Thank you.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to