public static void testWkbImportOnPostgresST() { try { java.sql.Connection con = java.sql.DriverManager.getConnection("jdbc:postgresql://tb.esri.com:5432/new_gdb" , "tb", "tb"); com.esri.core.geometry.OperatorFactoryLocal factory = com.esri.core.geometry.OperatorFactoryLocal .getInstance(); com.esri.core.geometry.OperatorImportFromWkb operatorImport = (com.esri.core.geometry.OperatorImportFromWkb )factory.getOperator(com.esri.core.geometry.Operator.Type.ImportFromWkb); string stmt = "SELECT objectid,sde.st_asbinary(shape) FROM new_gdb.tb.interstates a WHERE objectid IN (2) AND (a.shape IS NULL OR sde.st_geometrytype(shape)::text IN ('ST_MULTILINESTRING','ST_LINESTRING')) LIMIT 1000"; java.sql.PreparedStatement ps = con.prepareStatement(stmt); java.sql.ResultSet rs = ps.executeQuery(); while (rs.next()) { byte[] rsWkbGeom = rs.getBytes(2); com.esri.core.geometry.Geometry geomBorg = null; if (rsWkbGeom != null) { geomBorg = operatorImport.execute(0, com.esri.core.geometry.Geometry.Type.Unknown , java.nio.ByteBuffer.wrap(rsWkbGeom), null); } } ps.close(); con.close(); } catch (System.Exception) { } }
/// <summary> /// Writes specified output to table in database </summary> /// <param name="output"> </param> public virtual void writeOutput(double[] output) { try { string sql = "INSERT " + tableName + " VALUES("; for (int i = 0; i < output.Length; i++) { sql += "?"; if (i < (output.Length - 1)) // add coma if not last { sql = ", "; } } sql += ")"; // for (int i = 0; i < output.length; i++) { // sql += output[i]; // if (i < (output.length - 1)) { // sql = ", "; // } // } // Statement stmt = connection.createStatement(); java.sql.PreparedStatement stmt = connection.prepareStatement(sql); for (int i = 0; i < output.Length; i++) { stmt.setDouble(i, output[i]); } stmt.executeUpdate(sql); stmt.close(); } catch (java.sql.SQLException ex) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw new NeurophInputException("Error executing query at JDBCOutputAdapter", ex); } }