If the Java language in the backend JSP file operates the JGeometry object provided by OracleSpatial

Source: Internet
Author: User

If the Java language in the backend JSP file operates the JGeometry object provided by OracleSpatial

Write down a flow account and record how to solve this problem that has plagued you for a long time. At that time, I thought I had tried all of the attempts and wondered how to solve them. Finally, I solved the problem ~

The correct code is as follows:

 

<% @ Page contentType = "text/html; charset = gb2312" language = "java" import = "java. SQL. *, java. lang. *, oracle. spatial. geometry. *, oracle. spatial. util. *, oracle. SQL. * "errorPage =" "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN "" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <Html xmlns =" http://www.w3.org/1999/xhtml "> <Head> <meta http-equiv =" Content-Type "content =" text/html; charset = gb2312 "/> <title> no title text </title> The map is on port 8888, And the jsp file is under the project folder created under the webapps folder under the tomcat folder and on port 8080. Run the following code in chrome:

 

 

response.addHeader("Access-Control-Allow-Origin", "http://192.168.14.216:8888");

The JGeometry object is provided in sdoapi. jar. Sdoapi. jar and sdoutl. jar are required. Therefore, you need to import the corresponding package in the import header: oracle. spatial. geometry. *, oracle. spatial. util. *, oracle. SQL .*

 

 

import="java.sql.*,java.lang.*,oracle.spatial.geometry.*,oracle.spatial.util.*,oracle.sql.*"

I previously imported oracle. spatial. geometry. *, oracle. jdbc. driver. *, oracle. SQL. STRUCT; oracle not imported. spatial. util. *. JGeometry errors may occur.

 

Previously, when loading jsp pages in the browser, the error JGeometry is of an undefined type. Later, I didn't report this error, but there was still a problem. I always thought it was still the problem and thought JGeometry was unavailable. (Because the JGeometry error is reported, sometimes the error is not reported .)

In the program, remove the sdo_geometry object through select geom, and then perform getObject and load. The index in getObject () refers to the total index, not the index of the Object. For example, the first attribute is String, and the second attribute is sdo_geometry. The values are getString (1) and getObject (2) in sequence ). I used to select * And then getObject (1), so there is a problem. (The first one from select * is String, and the second is sdo_geometry)

 

SQLStatement = "select geom from room where idc = "+sp;ResultSet res_room=stmt.executeQuery(SQLStatement);if(res_room.next()){  STRUCT dbObject=(STRUCT)res_room.getObject(1);  JGeometry geom=JGeometry.load(dbObject);


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.