import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Connection; import java.sql.DriverManager; import java.io.FileReader; public class GeometryTest { public GeometryTest(Connection c) throws Exception { PreparedStatement toGeom = c.prepareStatement("select GeomFromText(?)"); PreparedStatement toText = c.prepareStatement("select AsText(?)"); FileReader reader = new FileReader("Geom.txt"); char[] inChar = new char[100000]; int size = reader.read(inChar); String inText = new String(inChar, 0, size); System.out.println("Size " + size + " " + inText.substring(0, 80)); ResultSet rs = null; toGeom.setString(1, inText); rs = toGeom.executeQuery(); rs.next(); Object geom = rs.getObject(1); rs.close(); toText.setObject(1, geom); rs = toText.executeQuery(); rs.next(); String outText = rs.getString(1); System.out.println(outText.substring(0, 80)); rs.close(); c.close(); } public static void main(String[] args) { try { Class.forName(args[0]); Connection c = DriverManager.getConnection(args[1], args[2], args[3]); new GeometryTest(c); } catch (Exception e) { e.printStackTrace(); } } }