Updating spatial data USING JAVA

I want to update spatial data using java.Does anyone know how can i do this;;;
for example i have created the following table.
CREATE TABLE customers (
customer_id NUMBER,
last_name VARCHAR2(30),
first_name VARCHAR2(30),
street_address VARCHAR2(40),
city VARCHAR2(30),
state_province_code VARCHAR2(2),
postal_code VARCHAR2(9),
cust_geo_location SDO_GEOMETRY);
HOW CAN I UPDATE THE FIELD:cust_geo_location,
WHICH TYPE IS: SDO_GEOMETRY;;;;;
I wrote a programm in java, which updates the FIELD CUSTOMER_ID.
( rset.absolute(3);
rset.updateInt("CUSTOMER_ID",2222 );
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
rset.next();
rset.updateRow(); ).
---------- THE FULL JAVA PROGRAMM
import java.sql.*;
import java.io.*;
import java.util.Date;
public class update{
public static void main (String args [])
throws SQLException, IOException
System.out.println ("Loading Oracle driver");
try {
Class.forName ("oracle.jdbc.driver.OracleDriver");
catch (ClassNotFoundException e)
System.out.println ("Could not load the driver");
e.printStackTrace ();
System.out.println ("Connecting to the local database");
try{
Connection conn =
DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:XE", "sp", "spgianna");
Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
// String LAST_NAME,FIRST_NAME ;
int CUSTOMER_ID ;
ResultSet rset = stmt.executeQuery("SELECT CUSTOMER_ID FROM CUSTOMERS");
/* while ( rset.next() ) {
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
LAST_NAME = rset.getString("LAST_NAME");
FIRST_NAME = rset.getString("FIRST_NAME");
System.out.println( CUSTOMER_ID+""+LAST_NAME + " " +FIRST_NAME);
rset.absolute(3);
rset.updateInt("CUSTOMER_ID",2222 );
CUSTOMER_ID = rset.getInt("CUSTOMER_ID");
rset.next();
rset.updateRow();
System.out.println(CUSTOMER_ID);
catch(SQLException sqle) {
System.out.println("SQL Exception encountered: " );
} catch(Exception e) {
System.out.println("Unexpected Exception: " );
HOW CAN I UPDATE THE FIELD:cust_geo_location,
WHICH TYPE IS: SDO_GEOMETRY;;;;;;;;;;;;;;

Hi Guys,
Dont forget to close your stmt and connection after execution
Use this as a template if you like:
try{
     /**make connection**/
     ServerConnection sc = new ServerConnection();
Statement stmt = sc.conn.createStatement();
/**create statement & execute**/
String insertstmt = "insert into .......";
//execute
stmt.execute(insertstmt);
/**Close and catch exception**/
stmt.close();
sc.conn.close();
catch(SQLException sqlE){
     sqlE.printStackTrace();
     System.out.println(sqlE.getMessage());
As for the string "insertstmt" itself, this is where your standard SQL statement goes
So get it working using a standard SQL editor first, then copy and paste it in to this string variable. The string should be a series of concatenated strings and variables to recreate the SQL atatement in Java. For example
the SQL statement:
insert into Mytable(SESSIONID, TIME1) values ('300', '4.45pm' );
assuming the values are stored in variables called 'sessionnumber' and 'time'
will become
String stmt =
"insert into Mytable(SESSIONID, TIME1) values ('"+sessionnumber+"', '"+time+"')";
Hope this helps.
E
Ps. Do a system.out.println after you create the stmt. The statement printed out to the console should be a valid SQL statement that you can use in your editor. (minus the ;)
...keep working on the string until you can do this.

Similar Messages

  • How to use Spatial Java Class to update spatial data?

    Hi,
    I am new to Oracle and couldn't find enough information on how to update spatial data.
    Here are my questions?
    1)Where could I find Spatial Java Class Javadoc?
    2)I'd like to update spatial data inside a ResultSet.next() loop.
    After I got the Geometry object and Point object how do I change the x and y values of Point object and save it back to the database.
    3)
    GeometryAdapter sdoAdapter = OraSpatialManager.getGeometryAdapter("SDO", "8.1.6", null, STRUCT.class, null, conn);
    Can I use the above GeometryAdapter for saving Geometry back to database?
    4)
    SpatialReference sref = srManager.retrieve(8265);
    // SRID = 8265: LAT-LON (NAD 83)
    Do I need to create a SpatialReference object and why retrieve the SRID '8256'? Do I have to create SRID '8256'?
    Thanks for any help
    Gwowen

    You can find some sample code that shows you how to do that using
    the SDOAPI java library. Look under the "Sample Code" section on
    OTN's Spatial page:
    http://otn.oracle.com/sample_code/products/spatial/content.html
    The sample file SampleNewToSDO.java is what you will need.
    hoep this helps,
    -LJ

  • Jdbc-updating spatial data

    i looked to the next link:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
    I want to update spatial data.To the previous link i found how to update tables but not how to update tables which contain spatial data.For example:
    CREATE TABLE customers (
    customer_id NUMBER,
    last_name VARCHAR2(30),
    first_name VARCHAR2(30),
    street_address VARCHAR2(40),
    city VARCHAR2(30),
    state_province_code VARCHAR2(2),
    postal_code VARCHAR2(9),
    cust_geo_location SDO_GEOMETRY);
    INSERT INTO customers VALUES
    (1001,'Nichols', 'Alexandra',
    '17 Maple Drive', 'Nashua', 'NH','03062',
    SDO_GEOMETRY(2001, 8307,
    SDO_POINT_TYPE (-71.48923,42.72347,NULL), NULL, NULL));
    if i want to update the costumer position (-71.48923,42.72347) how can i do this;;;

    Try posting this to the JDBC forum:
    http://forum.java.sun.com/forum.jspa?forumID=48

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to convert MS SQL Server data to XML data using Java

    Hi all!
    How do I generate XML document for SQL Server data using java / jsp.
    Thanks in advance

    http://www.fdsapi.com

  • 'Stale data error' is encountered while trying to update the data using EO.

    Hi,
    I am getting the following error when I am trying to update the data using EO:
    '' Unable to perform transaction on the record. \nCause: The record contains stale data. The record has been modified by another user. \nAction: Cancel the transaction and re-query the record to get the new data."
    I have tried clearing the corresponding VO cache and have also used the "getTransaction().setClearCacheOnCommit(true)" method in the AM, but the error persists.
    Kindly suggest some work around for this problem.

    Chirag,
    this error is usually.... thrown by framework, if some other user has updated the same record you are trying to update by your EO, just check db, and try for a different record!
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need Sample Code in C#  to Insert,Update,Query data using W 2.0 wsdl

    Hi,
    Can anyone please share sample code in C# to Insert,Update,Query data using W 2.0 wsdl.
    Thanks in advance

    I have found solution.
    Need add following line for non string data type.
    objOutreachUpdateList.Opportunity[0].IndexedNumber0Specified = true;

  • DISPLAY SPATIAL DATA USING JDBC ON A JAVA FRAME

    I am trying to set up some spatial data and need help in getting some sample
    code for displaying the data on a Java Frame using JDBC.
    The shapes I am setting up are simple polygons, lines, circles. I was going
    through the samples in the demo directory under $ORACLE_HOME/md/demo/examples, but could not find any JDBC
    I would really appreciate if you can point me towards some sample code and any other spatial resources.
    Madhukar

    Here you go. It uses JDBC to fetch geoms, convert them into Java JGeometry objects, which then create Java2D shapes (these are functions of the public sdoapi.jar library). It then uses some class in the sdovis.jar library (the rendering engine of MapViewer) to setup the necessary viewport transform. If you know how to setup the viewport transform, then you dont even need sdovis. sdovis.jar is found in an deployed MapViewer's WEB-INF/lib directory. Or you can extract it from the mapviewer.ear's web.war file.
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.util.*;
    import oracle.jdbc.OracleDriver;
    import oracle.sdovis.*;
    import oracle.sdovis.style.*;
    import oracle.sdovis.util.*;
    import oracle.spatial.geometry.JGeometry;
    import oracle.sql.STRUCT;
    * A very simple program that shows stuff from db in a JFrame
    * <p>
    public class tilsvgui2 extends JFrame
      final static int mapWidth  = 640;
      final static int mapHeight = 480;
      static JSDOGeometry geom = null;
      public tilsvgui2()
        setSize(mapWidth+40, mapHeight+40);
                    setVisible(true);
        this.addWindowListener(new java.awt.event.WindowAdapter() {
          public void windowClosing(WindowEvent e) { System.exit(0); }
            public void paint(Graphics g)
                    super.paint(g);
        int w = this.getWidth(), h = this.getHeight();
        Insets inset = this.getInsets();
        double[] mbr = geom.getMBR();
        //from sdovis; it will setup the viewport transform
        XFViewPort xfp = new XFViewPort();
        xfp.setDeviceView(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
        xfp.setDataView(mbr[0], mbr[1], mbr[2], mbr[3]);
        AffineTransform af = xfp.getAffineTransform();    //get the viewport transform
        Shape shp = geom.createShape(af);    //create a proper shape that fits the viewport
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.red);
        g2.drawRect(inset.left, inset.top, w-inset.left-inset.right-1, h-inset.top-inset.bottom-1);
        //draw the shape itself
        g2.setColor(Color.blue);
        g2.draw(shp);
      public static void getStuff() throws Exception
        System.out.println("Loading geometry...");
        Connection conn = getConnection("mapsrus.us.oracle.com", "1521", "orcl", "scott", "tiger");
        Statement  stmt = conn.createStatement();
        ResultSet  rset = stmt.executeQuery("select geom, totpop from counties where county='Merrimack' and state_abrv='NH'");
        while(rset.next())
          STRUCT st = (STRUCT) rset.getObject(1);
          geom = JSDOGeometry.loadFromDB(st);
          int population = rset.getInt(2);
          break; //displaying only the first geometry
        rset.close();
        stmt.close();
        conn.close();
      private static Connection getConnection(String host,
                                              String port,
                                              String sid,
                                              String username,
                                              String password)
        throws SQLException
        String thinConn = "jdbc:oracle:thin:@"+host+":"+port+":"+sid;
        Driver d = new OracleDriver();
        Connection conn = DriverManager.getConnection(thinConn,username,password);
        conn.setAutoCommit(false);
        return conn;
      public static void main(String[] args)
        try{
          getStuff();
        }catch(Exception e)
          e.printStackTrace(System.err);
        new tilsvgui2();
    }

  • Best option to push Mass data using Java API

    Hi All,
    Can any one let me know how Java API push data to MDM? Is it a good option when ti comes to perfromance point of view? We have around 2000/5000 records to be imported every time using Java API and wondering what would be best way to acheive this using Java API?
    Is java API is best option than Web services?
    Thanks
    Rajeev

    Rajeev,
    It is perfectly fine to use API to push data into MDM, you just need to make sure that your API does all those tasks which import manager does by default. For example, it should know when to insert and when to update. if an error happens during insertion of record, you should be able to notify the users.
    Having said that, where does the number 2000/5000 comes in? will you be creating users in batch and then invoke MDM API to store these in a single shot or willl it be a delta insert/update from Java to MDM?
    Thanks
    Aamir

  • How do I get pages 5.2 to automatically update the date - use 10.9.2

    How do I get pages 5.2 to automatically update the date in my documents - before the update I could do this. Does anybody have the knowledge or a workaround.
    If not I will dump pages 5.2 and use my old version!!! this feature is important for any and all businesses using pages??
    Any advice on how to achieve this is greatly appreciated
    I use a number of macs all using OSX
    10.9.2

    I have the same problem.
    What confuses me is that all the apple provided templates in pages seem to auto update their time and date upon opening.
    So there MUST be a way to do it... Ive been unable to work out how...
    Amnon

  • Updating system registries using java

    Hi,
    I�m writing a java installer for one of our tool. In that process, I want to update the �path� and �classpath� system variables. I know I have to update the system registry. But I don�t know how to do it using java.
    Can u tell me how to do it. And can u throw me more light on this.

    Hi
    I don't have much experiance with this...but one suggestion is...
    Registry changes are configured in files name Administrative (ADM) templates. You can update that file and the automatic registry mechanism will update it automatically for you.... for more help u can go to...
    http://www.windowsecurity.com/articles/Pushing-Out-Security-Settings-Configured-Registry.html
    hope it would be useful to u..

  • Problem with updating pricing date using BAPI_SALESORDER_CHANGE

    Hi,
    I need to update pricing date on sales order (but only on item level).
    I have been trying to use  BAPI_SALESORDER_CHANGE but nothing changes.Bapi returns no errors, ends with success.
    I hoped that bapi would change not only pricing date but also recalculate things the date affected.
    Here is my code:
    ls_head_inx-updateflag = 'U'.
    ls_bapisdls-pricing = 'C'.
    ls_item-itm_number = sales_order_posnr
    ls_item-price_date = new_price_date
    APPEND ls_item TO lt_item.
    ls_item_inx-itm_number = sales_order_posnr
    ls_item_inx-updateflag = 'U'.
    ls_item_inx-price_date = 'X'.
    APPEND ls_item_inx TO lt_item_inx.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
              EXPORTING
                salesdocument     = sales_order
                order_header_inx = ls_head_inx
                logic_switch         = ls_bapisdls
              TABLES
                return                 = lt_return
                order_item_in     = lt_item
                order_item_inx   = lt_item_inx
    Thanks & Regards,
    Mario

    Mario,
    I run same code as yours and work for me fine, able to update ITEM pricing date.
    I suppose you are using BAPI_TRANSACTION_COMMIT after your BAPI call, then only it will work.
    Also note that VBKD table stores this date for header and item. In my system, there are generally only header rows in that table, but a new item row gets generated when I change the item date with the BAPI to some other date. Also, this BAPI sometimes issues a W message instead of ERROR for something like non-existing items, so carefully check your RETURN table too.
    'Item 000002 does not exist' as WARNING message, so might be considering it as a success.
    If nothing works, try to do the same thing for the same data using VA02 and check . If that works, BAPI will work surely.
    Regards,
    Diwakar

  • Query regarding Update the data using application

    I have scenario i need to update single record in the the application and insert into a table
    for example
    SELECT ContactID,FirstName,MiddleName,LastName,Description FROM Contact
    Contact table contains 4 columns as explained. in the application there is one tab called Contact where it displays Above information
    and description is non editable.
    Now the new requirement has come user can update the description information and save information in a new column say 'Description1'
    that means new column needs to be added in the db and also necessary changes needs to be done at the application side
    For ex :SELECT ContactID,FirstName,MiddleName,LastName,Description,Description1 FROM Contact
    Now when user views the contact table it should display description info by default from 'description' table.
    If he edits he should see edited data from 'description1' table.
    Can any body guide me please and send me sample update query please, and the logic should if updated data is there display that data from
     'description1' table other wise display from  'description' table
    Smash126

    Hi Smash126,
    You need to fire the update command once you have filled the description record. It should happen on the primary key column of the record.
    For Example: 
    UPDATE Contact
    SET Description  = 'New Description',
    Description1 = 'New Description'
    where contactID = <<ContactID from application>>
    This way both will updated to same value, and next time you will get the updated value.
    Here is some ADO.Net links:
    http://www.codeproject.com/Articles/1155/Simple-ADO-NET-Database-Read-Insert-Update-and-Del
    http://www.onlinebuff.com/article_step-by-step-select-insert-update-and-delete-using-aspnet-c-and-adonet_32.html
    Regards Harsh

  • How to read azure storage data using JAVA with REST API

    Hi,
    We have a cloud service in our lab. We have enabled diagnostics
    in cloud services. So WADPerformanceCounterTable was created in storage account. Now , We want to read the WADPerformanceTable using
    JAVA with REST API. Is there any way to collect these details. please give me any
    sample code to connect azure storage using table service REST API.
    Thanks & Regards
    Rathidevi

    Hi,
    Please have a look at this article:
    https://convective.wordpress.com/2010/08/18/examples-of-the-windows-azure-storage-services-rest-api/, it demonstrate how to use table service Rest API, it also give us the code, hope this helps. Of course, the
    MSDN article could also help us coding.
    Best Regards,
    Jambor
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How To Update The Registry using Java

    I want to open up the registry and place my Java Application in the Startup using Java.Opening the Registry is done with the use of Exec() now how to add my program in the startup.
    Tx in Advance.
    gomes

    Search the forum - I've already answered similar questions about 10 times.

Maybe you are looking for

  • Can I import a song into the garage band app and edit it?

    I'm a music teacher and I'm trying to cut out a few verses in a song for my students. How do I import a song into the garbage app?

  • Printable and Graphics in JavaFX - future strategy?

    Hi all, I need JavaFX for a business application that requires reporting, printing and also a print preview. What would be the best approach for creating complex layouts (text, tables, graphics, images, graphs, various fonts etc.), having the applica

  • NavigationPane in ul tag

    This code makes a menu in a HTML table. <af:navigationPane id="pt_np2" hint="tabs" level="1" var="menuInfo" value="#{root_menu}"> <f:facet name="nodeStamp"> <af:commandNavigationItem text="#{menuInfo.label}" id="pt_cni2" destination="#{menuInfo.desti

  • ID CS3 5.0.3 / Leopard 10.5.4 Crashing on Save/Export

    We have a massive productivity problem that we cannot solve. ID CS3 5.0.3 running on a PPC iMac, with OS 10.5.4 Every time we try to save/save as or export a PDF, InDesign "unexpectedly closes." This has slowed work on this computer to an absolute cr

  • Bloquear Titular de los documentos ?

    - Buenos días comunidad SAP quiero bloquear el titular de los documentos, pero ni por parametrización de formulario, ni por autorizaciones generales lo e podido hacer. Gracias por la ayuda de antemano.