Oracle's spatial database operation driver updated, the new driver for Oracle8.0 or above, the new driver in the database operation above and the original driver difference is larger, but one thing: the use of simple
The steps to build a spatial database and to create a spatial index are skipped, and there are many examples on the web, and the implementation is unchanged, and the following list of code to add a space database record:
Import java.sql.*;
Import oracle.sql.*;
Import Oracle.spatial.geometry.JGeometry;
/**
* <p>title: </p>
*
* <p>description: </p>
*
* <p>copyright:copyright (c) 2006</p>
*
* <p>company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Sdoadd {
public static void Main (string[] args) {
String Driver = "Oracle.jdbc.driver.OracleDriver";
String url = "Jdbc:oracle:thin:@172.16.75.200:1521:starmap";
String uid = "Hmbst";
String PSW = "Hmbst";
Connection conn = null;
PreparedStatement Ps=null;
try {
Class.forName (driver);
conn = drivermanager.getconnection (URL, uid, PSW);
Jgeometry jgeometry=new jgeometry (41884696,14377039,0);
STRUCT obj =jgeometry.store (jgeometry,conn);
String sql =
"INSERT into POISDO values (Seq_poi_id.nextval,?,?)";
PS = Conn.preparestatement (sql,resultset.type_scroll_insensitive, resultset.concur_updatable);
Ps.clearparameters ();
Ps.setstring (1, "my Home");
Ps.setobject (2, obj);
Insert Point object Record
Ps.executeupdate ();
Conn.commit ();
}
catch (Exception ex) {
Ex.printstacktrace ();
}
Finally
{
if (conn!=null)
{
try {
Conn.close ();
}
catch (SQLException ex) {
Ex.printstacktrace ();
}
}
if (ps!=null)
{
try {
Ps.close ();
}
catch (SQLException ex) {
Ex.printstacktrace ();
}
}
}
}
}
The structure of table poisdo is as follows
create table poi (
id INTEGER,
gname VARCHAR2(256),
gshape MDSYS.SDO_GEOMETRY);