2 Replies Latest reply on Sep 8, 2011 10:53 AM by gimbal2

    OraclePreparedStatement

    886904

      public static void main(String[] args) throws Exception {
      OracleConnectionPoolDataSource ods = new OracleConnectionPoolDataSource();
      ods.setURL("jdbc:oracle:thin:@//localhost:1521/xe");
      ods.setUser("user");
      ods.setPassword("password");
      Connection c = ods.getConnection();
      OraclePreparedStatement st = (OraclePreparedStatement) c.prepareStatement("SELECT :start FROM dual");
      st.setObjectAtName("start", "0");
      ResultSet rs = st.executeQuery();
      while (rs.next()) {
      System.out.println(rs.getString(1));
      }
      }

      Exception in thread "main" java.sql.SQLSyntaxErrorException: ORA-01745: Invalid host/bind variable name

      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
      at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
      at OracleConnector.main(OracleConnector.java:22)

      Oracle 10g XE

      With name other than "start" it's works fine. WTF?