Hello, I'm facing an issue while using the JDBC driver to connect to a Plocal Orient DB. Here is my code:

            Properties info = new Properties();
    info.put("user", this.user);
    info.put("password", this.pwd);
    java.sql.DriverManager.registerDriver(new com.orientechnologies.orient.jdbc.OrientJdbcDriver());

    Connection conn = (OrientJdbcConnection) DriverManager.getConnection(this.url, info);

    String sql = "insert into personne (name) values(?)";
    PreparedStatement stmt = conn.prepareStatement(sql);
    stmt.setString(1, "test recuperation RID par jdbc");

    ResultSet rs = stmt.executeQuery();
    ...

And here the exception stack;

Exception in thread "main" com.orientechnologies.orient.core.exception.OCommandExecutionException: Cannot execute non idempotent command at com.orientechnologies.orient.core.storage.OStorageEmbedded.executeCommand(OStorageEmbedded.java:90) at com.orientechnologies.orient.core.storage.OStorageEmbedded.command(OStorageEmbedded.java:85) at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:69) at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:82) at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:29) at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.query(ODatabaseRecordAbstract.java:505) at com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.query(ODatabaseRecordWrapperAbstract.java:188) at com.orientechnologies.orient.jdbc.OrientJdbcPreparedStatement.executeQuery(OrientJdbcPreparedStatement.java:73) at org.octopus.dao.jeudonnees.impl.JdbcJeuDonneesDAO.create(JdbcJeuDonneesDAO.java:39) at org.octopus.dao.jeudonnees.impl.JdbcJeuDonneesDAO.create(JdbcJeuDonneesDAO.java:1) at org.octopus.tests.tests.main(tests.java:23)

It seems like it's not possible to run non idempotent commands using the Orient JDBC Driver. Thanks for your help

有帮助吗?

解决方案

The standard way to call an insert with JDBC is by using .executeUpdate():

http://www.mkyong.com/jdbc/jdbc-preparestatement-example-insert-a-record/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top