SDO_UTIL.FROM_KMLGEOMETRY and Java

Hello,
I'm trying to write a Java program that will parse a KML file, convert KML geometry coordinates into SDO_GEOMETRY coordinates, then insert appropriate records into the database.
I'm stuck on the 2nd part, converting KML into SDO_GEOMETRY. Here's my code:
private static void getSDOGeom(Connection con, String [] geomKML, JGeometry [] geomSDO) throws Exception {
CallableStatement s = con.prepareCall("{? = call SDO_UTIL.FROM_KMLGEOMETRY(?)}");
ResultSet rs = null;
for (int i = 0; i < geomKML.length; i++) {
s.registerOutParameter(1, JGeometry.GTYPE_POINT);
s.setString(2, "\'<Point><coordinates>" + geomKML[i] + "</coordinates></Point>\'");
rs = s.executeQuery();
geomSDO[i] = (JGeometry) s.getObject(1);
Here's my error message:
java.sql.SQLException: ORA-06550: line 1, column 13:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
-then stack trace saying which line of my program caused the error - the executeQuery line.
It looks like my problem is from the JGeometry.GTYPE_POINT in the registerOutParameter method call. I've tried a number of items here to no effect. The geomKML array contains KML coordinates stripped from a KML/XML file, I had to put the <Point> and <coordinates> tags in because the XML parser isn't including them. I've converted coordinates directly in the database, so I know the KML input is correct. The geomSDO array is of the proper size, but is null. I'm not sure what I'm doing wrong and can't find anything like this in the forums. A DB guy here at work did some searching and said I should use JGeometry, but he's not sure why it isn't working either.
Anyone have any ideas?

Thanks for the help... my problem was the ResultSet. I didn't noticed until your most recent code example that you weren't using it, but were acting upon the CallableStatement directly for the getObject method. I was using CallableStatement wrong. I think I saw an example somewhere with the CallableStatement and the ResultSet both being used. Thanks for the STRUCT code too, I saw something about that in a forum post, but wasn't sure what it was doing... but my code doesn't work without it. I did have to track down the jar libraries and imports for STRUCT and OracleType, but that wasn't too difficult.
As to your other points, there is a bit of a misunderstanding because of the limited information I posted - I should have been more clear. This method is one method in a larger program - my database connection was already set up and working, though I thank you for being proactive and including it just in case. I was also printing out my KML coordinates to check to make sure they were ok and had already tested them in the database with a written procedure and knew they were working. The "\" was an escape character for a single quote, which I thought I needed to include because the input to FROM_KMLGEOMETRY needed to be surrounded by single quotes in the database testing. Your initial response also included them. I found that by removing them, my error went away - in fact, I didn't even notice they were there at first. Finally, the JGeometry array does indeed work and the array list isn't needed. I was hoping the array would work as it's more light weight and I'm able to pass the object by reference instead of by value, decreasing the overhead of my code. I was delighted to find that it did work once I fixed the ResultSet issue as previously mentioned. It is initialized elsewhere in my code to be the same size as the array with the KML geometry.
I don't add the comments above to rebuff you. I'm very glad to you provided extremely complete answers. You've helped me before. I add them in case someone else stumbles upon this thread in hopes that the information will be useful to them.
For posterity, Final code with related imports:
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DriverManager;
import oracle.spatial.geometry.JGeometry;
import oracle.jdbc.OracleTypes;
import oracle.sql.STRUCT;
private static void getSDOGeom(Connection con, String [] geomKML, JGeometry [] geomSDO) throws Exception {
CallableStatement s = con.prepareCall("{? = call SDO_UTIL.FROM_KMLGEOMETRY(?)}");
STRUCT geomSDO_STRUCT = null;
for (int i = 0; i < geomKML.length; i++) {
s.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
// You could also add extrude, tessellate and altitudeMode
s.setString(2, "<Point><extrude>0</extrude><tessellate>0</tessellate>" +
"<altitudeMode>clampToGround</altitudeMode><coordinates>" + geomKML[i] +
"</coordinates><extrude>0</extrude><tessellate>0</tessellate>" +
"<altitudeMode>clampToGround</altitudeMode></Point>");
s.executeQuery();
geomSDO_STRUCT = (STRUCT) s.getObject(1);
geomSDO[i] = JGeometry.load(geomSDO_STRUCT);
s.close();
The libraries that I needed to add to the project at compile time (already had the jdbc driver loaded for runtime) are
sdoapi.jar (this is for JGeometry and other spatial related items) located <oracle home>/md/jlib/
ojdbc6.jar (this is where the STRUCT and OracleTypes are found) located <oracle home>/jdbc/lib/
Thanks,
Edit:
If you're trying to write SDO_GEOMETRY to a database, this thread will help.
ORA-00939: too many arguments for function
Edited by: J-rd-n on Sep 14, 2010 11:44 AM

Similar Messages

  • Whats is difference between Java JRE  and  Java SDK

    Hi,
    what is the difference between Java JRE and Java SDK...
    i think both of them have the same set of files to be installed...
    I am not able to understand where they differ

    The JRE (Java runtime Environment) contains just the stuff necessary to run Java and the SDK (System Development Kit) contains the extra stuff necessary (and also helpful) to develop in Java.

  • What is difference between C# Gzip and Java swing GZIPOutputStream?

    Hi All,
    I have a Java swing tool where i can compress file inputs and we have C# tool.
    I am using GZIPOutputStream to compress the stream .
    I found the difference between C# and Java Gzip compression while a compressing a file (temp.gif ) -
    After Compression of temp.gif file in C# - compressed file size increased
    while in java i found a 2% percentage of compression of data.
    Could you please tell me , can i achieve same output in Java as compared to C# using GZIPOutputStream ?
    Thank a lot in advance.

    797957 wrote:
    Does java provides a better compression than C#?no idea, i don't do c# programming. and, your question is most likely really: "does java default to a higher compression level than c#".
    Btw what is faster compression vs. better compression?meaning, does the code spend more time/effort trying to compress the data (slower but better compression) or less time/effort trying to compress the data (faster but worse compression). most compression algorithms allow you to control this tradeoff depending on whether you care more about cpu time or disk/memory space.

  • What is the diffrence between package javax.sql and java.sql

    Is javax designed for J2EE?
    And when to use package javax?

    Hi,
    What is the diffrence between package javax.sql and java.sql?The JDBC 2.0 & above API is comprised of two packages:
    1.The java.sql package and
    2.The javax.sql package.
    java.sql provides features mostly related to client
    side database functionalities where as the javax.sql
    package, which adds server-side capabilities.
    You automatically get both packages when you download the JavaTM 2 Platform, Standard Edition, Version 1.4 (J2SETM) or the JavaTM 2, Platform Enterprise Edition, Version 1.3 (J2EETM).
    For further information on this please visit our website at http://java.sun.com/j2se/1.3/docs/guide/jdbc/index.html
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Micro Systems
    http://www.sun.com/developers/support/

  • What is the diffrence between My Runnable Interface and Java Runnable

    Hi folks
    all we know that interfaces in java just a decleration for methods and variables.
    so my Question is why when i create an interface its name is "Runnable" and i declared a method called "run" inside it.then when i implements this interface with any class don't do the thread operation but when i implement the java.lang.Runnable the thread is going fine.
    so what is the diffrence between My Runnable Interface and Java Runnable?
    thnx

    Hi folks
    all we know that interfaces in java just a decleration
    for methods and variables.
    so my Question is why when i create an interface its
    name is "Runnable" and i declared a method called
    "run" inside it.then when i implements this interface
    with any class don't do the thread operation but when
    i implement the java.lang.Runnable the thread is going
    fine.
    so what is the diffrence between My Runnable Interface
    and Java Runnable?
    thnxClasses and interfaces are not identified by just their "name", like Runnable. The actual "name" the compiler uses is java.lang.Runnable. So even if you duplicate the Runnable interface in your own package, it's not the same as far as the compiler is concerned, because it's in a different package.
    Try importing both java.util.* and java.awt.* (which both have a class or interface named List), and then try to compile List myList = new ArrayList();

  • Java SE and Java EE

    I am a IT graduate and I still need some clarification on the relationship between Java SE and Java EE API. Does EE include SE?
    For application development, I know I can use only SE without the EE, but can I use EE alone without SE?
    Any good articles addressing my questions?
    Thank you very much
    R

    Java EE in fact extends java SE, its primarily aim is to simplify developing multitier enterprise applications (Java SE provides all the necessary basic libraries etc.)
    Because Java EE is an extension of Java SE, you cant use EE without SE - without SE there is no EE.

  • SSO between Portal and Java WD application

    Hi Experts,
    I am using CE 7.2 on localhost and I am very new to SAP.
    I need to know how can I get SSO between Portal and Java WD.  I have a WD application that displays the logged in user using "IUser currentUser = WDClientUser.getCurrentUser().getSAPUser()", as well I can use "IUser user = UMFactory.getAuthenticator().getLoggedInUser()".  Both work.
    Q1. What is the difference in the 2 above?
    Q2. My WD application is set to authenticate user.  The WD application is in URL iView.  I need SSO between Portal and WD application.   Is there a way to get this SSO without SAP Backend (ECC), for now I just need SSO between Portal and Java WD appl.
    Everything is in localhost.
    Please advice. Thanks.

    > need to know how can I get SSO between Portal and Java WD.
    Then I suggest you ask your question in the Web Dynpro Java forum instead of the Web Dynpro ABAP one.

  • J2me and java card, need help to communicate

    we are trying to put together a reader to read smartcards using j2me and we figure that it would be easiest if we could develop it to work with java cards rather than standard smart cards, the problem is we get garbage when we communicate to it, the chip sends us crap, any suggestions what might be wrong, any calls we might be missing, has anyone worked with j2me and java cards or smart cards, any help would be appreciated.
    einar

    .... reader app and the ME behind it .... smells like mobile ....
    First of all - if you want to have one mobile application running on this just make sure that whatever is written in ME can use drivers from the reader chip ....
    Workin on the PC is something completely different. There was one good example how to develop one host application in Java provided with the JCOP tools long ago ... I don't know if this is now in the new Eclipse tools.
    But - there was a small API provided that can give you good hints what to do - and - once you have it on the reader side - you can easily integrate ME methods with this ...

  • Eclipse 3.4 and Java 6 compatibility

    Hi All,
    I have a tomcat plugin inside Eclipse 3.4.2. Recently I upgraded from Java 5 to Java 6. When I try to start Tomcat from Eclipse,I get the following error:
    Error occurred during initialization of VM
    java.lang.UnsatisfiedLinkError: java.lang.Float.floatToIntBits(F)I
         at java.lang.Float.floatToIntBits(Native Method)
         at java.lang.Math.<clinit>(Math.java:801)
         at sun.net.www.ParseUtil.lowMask(ParseUtil.java:512)
         at sun.net.www.ParseUtil.<clinit>(ParseUtil.java:559)
         at sun.misc.Launcher.getFileURL(Launcher.java:388)
         at sun.misc.Launcher$ExtClassLoader.getExtURLs(Launcher.java:165)
         at sun.misc.Launcher$ExtClassLoader.<init>(Launcher.java:137)
         at sun.misc.Launcher$ExtClassLoader$1.run(Launcher.java:121)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.Launcher$ExtClassLoader.getExtClassLoader(Launcher.java:118)
         at sun.misc.Launcher.<init>(Launcher.java:51)
         at sun.misc.Launcher.<clinit>(Launcher.java:39)
         at java.lang.ClassLoader.initSystemClassLoader(ClassLoader.java:1304)
         at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1286)
    Kindly suggest what needs to be done? If I am posting it in a wrong forum please suggest me the right one too.
    I would like to know if Eclipse 3.4 and Java 6 are compatible or not.
    Thanks in advance.

    ShubhaPradeep wrote:
    I have a tomcat plugin inside Eclipse 3.4.2. Recently I upgraded from Java 5 to Java 6. When I try to start Tomcat from Eclipse,I get
    Error occurred during initialization of VM
    java.lang.UnsatisfiedLinkError: java.lang.Float.floatToIntBits(F)IAre we talking 64-bit Linux?
    I had issues launching eclipse on CentOS 5 64-bit and Sun JDK 1.6,
    resolved by launching eclipse with the -vm option specifying Sun JDK 1.5 java.
    [https://www.centos.org/modules/newbb/viewtopic.php?post_id=95784&topic_id=11661]

  • Problem with win2000sp3 and Java web start

    I have JRE and Java web start (1.2.0_01, build b01) which come downloading file j2re-1_4_1_01-windows-i586-i.exe from sun.
    I have win2000pro running on my PC.
    I had updated win2000 to service pack 2 and everything was fine.
    Now i decided to update to service pack 3 (in the process I also updated other components) from Microsoft and:
    1) Java applets seem to be running fine within i.e.
    2) If i try to run an application from java web start my PC freezes and I have to restart it.
    3) Staroffice 6.0, which runs on Java, seems to be fine.
    I reinstalled both sp3 and jre etc, with no result.
    Is this a known problem?
    Thanks to all.
    Maurizio

    I suspect that you have hit a known problem with Swing on Java 1.4.1 with buggy video drivers. Do you have an ATI card? They are the worst offenders. ATI released new drivers for its Radeon line today. They fix the problem.

  • Problem with JSP and Java Servlet Web Application....

    Hi every body....
    I av developed a web based application with java (jsp and Java Servlets)....
    that was working fine on Lane and Local Host....
    But when i upload on internet with unix package my servlets and Java Beans are not working .....
    also not access database which i developed on My Sql....
    M using cpanel support on web server
    Plz gave me solution...
    Thanx looking forward Adnan

    You need to elaborate "not working" in developer's perspective instead of in user's perspective.

  • Report Script returns no data and "java.io.FileNotFoundException" error

    When attempting to write to a new file (Eg: C:\TEST.txt), Report Script returns no data and "java.io.FileNotFoundException" error occurs.
    This error occurs only in Essbase 9.3.1.3 release, however it works fine in release 9.3.1.0.
    After running the report the script, it pops up the follwing message:
    "java.io.FileNotFoundException: ..\temp\eas17109.tmp (The system cannot find the file specified): C:\TEST.txt"
    When checked the TEST.txt, it was empty.

    Sorry folks, I just found out the reason. Its because there was no data in the combination what I was extracting.
    but is this the right error message for that? It should have atleast create a blank file right?

  • I continually get a Java error. I've uninstalled and reinstalled firefox and nothing has helped. I've updated flash and Java.

    I have used Firefox as my default browser for many years. I've recently started getting a Java error message. It pops up continually. I have updated flash and java. I have uninstalled and re-installed Firefox and nothing has helped. I have had to start using Chrome instead of Firefox which I don't care for but I don't have the java error with Chrome. How do I fix this problem? The error reads as follows:
    Java Script Application
    Error: syntax error

    Your '''JavaScript''' error has nothing to do with the Java plugin . It is likely caused by an added extension (the earlier forum threads [/questions/944619] and [/questions/943088] mention disabling or updating the Social Fixer extension will resolve the problem).
    You can read this article for help troubleshooting your extensions: [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]

  • Java plugin doesn't work, even though it's installed correctly and java programs work.

    As stated. I have a link in ~/.mozilla/plugin that points to test/jre/plugin/i386/ns7/libjavaplugin_oji.so, which is the java 6 update 21 runtime environment.
    Java doesn't show in about:plugins, and java applets don't start (firefox suggests to install missing plugins).
    Java programs using the jre outside the browser work.
    This is on Linux 32-bits, Slackware 13.0, kernel 2.6.34.

    <blockquote>As stated. I have a link in ~/.mozilla/plugin that points to test/jre/plugin/i386/ns7/libjavaplugin_oji.so, which is the java 6 update 21 runtime environment.
    </blockquote>
    Where did you read that?<br />
    See http://kb.mozillazine.org/Java<br />
    In Firefox 3.6 and later versions you need the Next-Generation Java™ Plug-In present in Java 6 U10 and later (Linux: libnpjp2.so; Windows: npjp2.dll).
    http://java.com/en/download/faq/firefox_newplugin.xml
    http://java.sun.com/javase/6/webnotes/install/jre/manual-plugin-install-linux.html
    <pre><nowiki>ln -s /usr/local/java/jre1.6.0_20/lib/i386/libnpjp2.so libnpjp2.so
    ln -s /usr/lib/jvm/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins/libnpjp2.so (java-1_6_0-sun-plugin)
    </nowiki></pre>

  • How do I enable flash and java on firefox23 as I have the latest versions installed yet the plugin page shows "disabled" with no option to enable

    I have updated to Firefox 23 and it disabled my Java and Flash plugins. I then updated these to Flash 11.8.800.94 and Java to Version 7 Update 25. Now these are showing up on the plug in page but are showing "disabled" with no option to enable. How do I enable them to view content on the web.

    Thanks Philipp but i have already done that and the content started working...
    However, when i closed and restarted the browser it returned back to the same settings...
    I dont think that should happen, but anyway thank you for the solution. At least I can use it by resetting the values if need be
    Appreciate your help

Maybe you are looking for

  • Is It Possible To Create Different Personnel Number For One Employee

    HI Experts,         My Client need to get Different Personnel number for one employee,i.e for Trainee one Personnel number need to generate and same person when moving from Trainee to Probation another new personnel number should generate and again w

  • Refresh Idoc Metadata in PI 7.31 Java Only

    Hello experts, We are facing issue to refresh the Idoc metadata every time when we change Idoc structure in ECC for Idoc outbound scenario. We have imported the latest Idoc structure in ESR and assigned that to MM,OM and IFolw. Still in message monit

  • How do I get rid of these rough unfinished lines at the top?

    Hi I tried to attach this image in an ai file, but I got an error saying this: [The content type of this image is not allowed.] Does anyone know why I can't send this ai file. It's not too big, it's only 194 kb. Anyway, my other question refers to th

  • Unable to collect the changed query elements to a transportable request

    Hi All, I had saved the query changes to dummy request, now I have to collect the changed qurey elements in a transportable request. This I am doing in the transport connection tab in rsa1. Now I want to collect only the changed elements of the query

  • Method not found in class errors when compiling project

    Hi, I am getting the following errors when compiling my project: Error(3,8): ReqLinesNotificationsVORowImpl not found Error(25,25): method getAttributeInternal(java.lang.String) not found in class oracle.apps.icx.por.wf.server.ReqLinesNotificationsVO