AnsweredAssumed Answered

Not able to insert in picomp table from Java

Question asked by PraveenCTS on Aug 6, 2015
Latest reply on Aug 6, 2015 by PraveenCTS

Hi All,

 

We are trying to connect to OsiPi Archive using JDBC. We are able to execute select query on picomp table.

Here is the code:

Connection con = null;

  String hostname = "myhostname";

  String dataSource = "mydatasource";

  String url = "jdbc:pisql://" + hostname + "/Data Source=" + dataSource + "; Integrated Security=SSPI;";

  

  String driver = "com.osisoft.jdbc.Driver";

  PreparedStatement stmt;

  ResultSet rs;

  Properties plist = new Properties();

 

  plist.put("user", "osiUser"); 

  plist.put("password", "osiPass");

  try {

   Class.forName(driver).newInstance();

   con = DriverManager.getConnection(url, plist);

   stmt = con.prepareStatement("SELECT tag, value FROM picomp WHERE tag like ?");

   stmt.setString(1, tagp);

   rs = stmt.executeQuery();

//extract results

   catch (SQLException  e) {

   e.printStackTrace();

  }

  catch (Exception  e) {

   e.printStackTrace();

  }

 

Now, when we try to insert into picomp table, we are getting following exception

 

java.sql.SQLException: [RDSA OLE DB Provider] IID_ICommand: Unspecified error (E_FAIL)

        at com.osisoft.jdbc.PreparedStatementImpl.executeUpdate(PreparedStatemen

tImpl.java:212)

        at getComp.main(getComp.java:44)

Caused by: com.osisoft.rdsa.RdsaException: [RDSA OLE DB Provider] IID_ICommand:

Unspecified error

(E_FAIL)

        at com.osisoft.rdsa.Command.ExecuteNonQueryP(Native Method)

        at com.osisoft.rdsa.Command.executeNonQuery(Command.java:66)

        at com.osisoft.jdbc.PreparedStatementImpl.executeUpdate(PreparedStatemen

tImpl.java:209)

        ... 1 more

 

Here is the code:

 

stmt = con.prepareStatement("insert into picomp (tag, value) values ('Test_Tag', 106)"); 

    Object c = ps.executeUpdate(); //line 44

   System.out.println(c);

 

Does anyone has any pointers as to why this exception is coming or what can we do about it.

 

Any pointers are appreciated.

 

Thanks

Praveen

Outcomes