JDBC insert empty STRUCT (JGeometry) into SDO_GEOMETRY

Hi!
I need to insert empty or null value intro oracle table with SDO_GEOMETRY field.
I'm using prepared statement.
I have tried pstmt.setNull(1, null), pstmt.setObject(1, null)
Normaly I do it like this:
STRUCT obj = JGeometry.store(jgeom, conn);
pstmt.setObject(1, obj);
So I probably need to create an empty STRUCT or something.
I have also tried using :
StructDescriptor type_descriptor = StructDescriptor.createDescriptor ("MDSYS.SDO_GEOMETRY", conn); but I don't know if I'm using it right.
The syntax is like:
StructDescriptor structdesc = StructDescriptor.createDescriptor (sql_type_name, connection); but I don't know what sql_type_name means? Is it tablename, fieldname? Tried them all...no success.
I've read that JDBC doesn't support that kind of insert with setNull, is there a workaround or any other way of doing this.
Thanks in advance and have a nice day.
Simon

http://www.oracle.com/technology/tech/java/sqlj_jdbc/pdf/a96654.pdf seems to have the clues that you are looking for.
BTW, we are adding a Connection.createStruct/Array method so that you can create these types of objects in portable with JDBC in JDBC 4

Similar Messages

  • Problem to insert  Chinese Characters(GB3212)  into MySQL

    I met a problem to insert Chinese Characters (GB3212) into MySQL using Entity Bean (or JPA).
    For example, when a hardcoded string "{color:#ff0000}电器me元件{color}" is inserted, it is displayed as "{color:#ff0000}??me??{color}" in MySQL.
    The NamedQuery is also not working for Chinese Characters.
    The setting are as following:
    GlassFish JDBC connection pool: useUnicode=true, charecterEncoding=gb2312
    NetBeans IDE: source encoding set to GB2312;
    MySql table: the column set to CHARACTER SET gb2312;
    Any experts, please give advice
    Thanks lot

    I didn't noticed that there is a {color:#ff0000}sun-resources.xml{color} file under {color:#ff0000}<ejb project>/server resources{color}.
    This file has a pool configuration. This config just overwite the paremeter i added using Admin Console every time a client is lauched. So there are two option to fix this problem.
    1. Insert the follwowing two lines into the {color:#ff0000}sun-resources.xml{color}
    <property name="characterEncoding" value="gb2312"/>
    <property name="useUnicode" value="true"/>
    2. delete the everthing in the {color:#ff0000}sun-resources.xml, using Admin Console {color}config your own pool & DataSource
    I tried first option & it works.

  • JDBC Insert

    hi folks,
    I have a oracle table with USER_ID as primary key.
    Using JDBC i m trying to insert a row with same USER_ID and hence violating primary key rule.
    try {
    stat.executeUpdate(SQL);
    catch(SQLException ex)
    Now JDBC throws me a sql Exception, with scary message "ORXXX ....."
    Is any other way to detect that i m violating primary key rule ?
    How abt firing a SQL query before i insert the new row into database.
    eg. select count(1) from table where USER_ID='X'.
    If count == 1, then i know that record already exits.
    But the downside is that, 2 SQL queries for a insertion. ?
    Ur thoughts will be greatly appreciated.

    As duffymo states a unique constraint is absolutely the right thing to do to ensure no two usernames are the same.
    To go back to an earlier point, once you have this unique constraint in place, if you want to avoid getting the unique constraint error if someone attempts to insert a username that already exists, or you want to be able to handle it you could:
    1) As you've already considered, you can test for the presence of the username prior to inserting. Results in additional round trip and there is of course a small period of time between testing for it and actually inserting that someone else might consume that username.
    2) You can get at the vendor-specific error code that caused a SQLException with SQLException.getErrorCode() and test for it. This has all the usual cavets that you'll be limiting your code to work on Oracle if you use this technique. Of course, this might not be an issue for your application and there are ways to isolate database-specific dependencies anyway.
    T

  • Wscompile insertion of schema types into wsdl file

    The <types/> element is empty in my WSDL file after I compile the web service with wscompile. The operation parameter type is String. I am using Apache XMLBeans. How do I configure wscompile in JWSDP 2.0 to insert the schema types into the WSDL file when it generates the WSDL?
    Thank you,
    Glenn

    The targetnamespace is used define the namespace for the definitions made in your schema.
    For example,
    <xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="foo">
    <xsd:complexType name="fred">
    </xsd:complexType>
    Then "Fred" will be in the "foo" namespace
    And if you had another schema in your wsdl like
    <xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="bar">
    <xsd:complexType name="fred">
    </xsd:complexType>
    Then you would have two "fred" types one in the "foo" namespace and one in the "bar" namespace.
    Then later on in your WSDL you could refer to either one.

  • How do I insert my Edge Animation into Wordpress as an animated/interactive graphic

    How do I insert my Edge Animation into Wordpress as an animated/interactive graphic?

    Hi ColleenSyron,
    Can you check out this video: http://tv.adobe.com/watch/create-like-crazy-with-adobe-edge/episode-5-spice-up-your-wordpr ess-site-with-edge-animate/
    Thanks,
    Preran

  • SharePoint List Form using InfoPath 2010 "Cannot insert the value NULL into column 'tp_DocId', table 'Content_SP_00003.dbo.AllUserData'; column does not allow nulls"

    I am experiencing issue with my SharePoint site , when I am trying to add new Item in List . Error given below :--> 02/03/2015 08:23:36.13 w3wp.exe (0x2E04) 0x07E8 SharePoint Server Logging Correlation Data 9gc5 Verbose Thread change; resetting trace
    level override to 0; resetting correlation to e2e9cddc-cf35-4bf8-b4f3-021dc91642da c66c2c17-faaf-4ff9-a414-303aa4b4726b e2e9cddc-cf35-4bf8-b4f3-021dc91642da 02/03/2015 08:23:36.13 w3wp.exe (0x2E04) 0x07E8 Document Management Server Document Management 52od
    Medium MetadataNavigationContext Page_InitComplete: No XsltListViewWebPart was found on this page[/sites/00003/Lists/PM%20Project%20Status/NewForm.aspx?RootFolder=&IsDlg=1]. Hiding key filters and downgrading tree functionality to legacy ListViewWebPart(v3)
    level for this list. e2e9cddc-cf35-4bf8-b4f3-021dc91642da 02/03/2015 08:23:36.17 w3wp.exe (0x1B94) 0x1A0C SharePoint Server Logging Correlation Data 77a3 Verbose Starting correlation. b4d14aec-5bd4-4fb1-b1e3-589ba337b111 02/03/2015 08:23:36.17 w3wp.exe (0x1B94)
    0x1A0C SharePoint Server Logging Correlation Data 77a3 Verbose Ending correlation. b4d14aec-5bd4-4fb1-b1e3-589ba337b111 02/03/2015 08:23:36.31 w3wp.exe (0x2E04) 0x07E8 SharePoint Foundation Database 880i High System.Data.SqlClient.SqlException: Cannot insert
    the value NULL into column 'tp_DocId', table 'Content_SP_00003.dbo.AllUserData'; column does not allow nulls. INSERT fails. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
    stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavi... e2e9cddc-cf35-4bf8-b4f3-021dc91642da 02/03/2015
    08:23:36.31* w3wp.exe (0x2E04) 0x07E8 SharePoint Foundation Database 880i High ...or runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream,
    Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,
    RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.SharePoint.Utilities.SqlSession.ExecuteReader(SqlCommand
    command, CommandBehavior behavior,

    Are you trying to setup P2P? Could you explain the process you followed completely? By anychance you create the backup and then created the publication?
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • Inserting a associative array into a table

    Hi,
    I am working on a process where I want to store the temporary results in an associative array. At the end of the process I plan to write the contents of the array into a table that has the same structure. (the array is defined as a %rowtype of the table)
    Is it possible to execute ONE sql statement that transfers the array into the table? I am on 10g (10.2.0.4.0)
    Here's what I have now:
    declare
      type t_emp is table of emp%rowtype index by pls_integer;
      v_emp t_emp;
    begin
      -- a process that fills v_emp with lots of data
      for i in v_emp.first .. v_emp.last
      loop
        insert into emp values v_emp(i);
      end loop;  
    end;But it would be better if the loop could be replaced by sql one statement that inserts all of v_emp into emp. Is that possible?
    Thanks!
    PS: I'm not sure whether it's a good idea to use this approach... building a table in memory and inserting it into the database at the end of the process. Maybe it's better to insert every record directly into the table... but in any case I'm curious to see if it is possible in theory :)
    Edited: Added version info

    True, SQL cannot access the PL/SQL type.
    So you can not do something like this:
    insert into emp
    select * from table(v_emp)That is not possible.
    But FORALL is possible:
    FORALL i in v_emp.first .. v_emp.last
        insert into emp values v_emp(i);FORALL makes just one "round trip" to SQL bulk binding the entire contents of the array.
    It is much more efficient than the normal FOR loop, though it is mostly a PL/SQL optimization - even the FORALL actually inserts the rows "one at the time", it just hands the entire array to the SQL engine in one go.
    If the logic has to be done procedurally, FORALL is efficient.
    If the logic can be changed so arrays can be avoided completely and everything done in a single "insert into ... select ..." statement, that is the most efficient.

  • When I insert an audio CD into my iMac, it automatically starts playing

    When I insert an audio CD into my iMac, it automatically starts playing, and I can't figure out why, nor how to stop this behavior. When I click in the upper right corner of my screen where it says "Finder", it shows the Finder as the only application running, and yet SOMETHING must be causing the CD to play. If it is an Extension that is being loaded, is it possible to terminate the Extensions one by one without restarting the computer to see which one is playing the CD?
    Is the OS9.1 operating system supposed to automatically play audio CD's when they are inserted into the iMac? Or could it be an Extension that is doing it?And if so, why is no means provided to actually CONTROL the playing of the CD (such as a control panel with PLAY, STOP, SKIP, etc. buttons)?
    On a PC, I can press Control/Alt/Delete to bring up the "Task List" that will show me ALL applications and processes currently running, and then terminate apps and processes one by one without having to restart the computer to see which one is playing the CD. Is there an equivalent way to display this information on an iMac that will show me which application or process or extension might be causing the audio CD to play, and allow me to terminate them one by one without restarting the computer until I can see which one is the "problem"?
    Jerry

    Hi, Jerry -
    Welcome to Apple's Discussions.
    Finder uses QuickTime in the background to do that, hence no specific app is shown in the Application menu (the far right item in the main menu bar) in addition to Finder.
    To unset automatic playing of CDs (and DVDs) -
    Open the QuickTime Settings control panel (Apple menu > Control Panels > QuickTime Settings).
    In that control panel, select AutoPlay from the pulldown menu in the control panel. Uncheck both the items shown in the new window. Close the control panel.
    No restart should be needed in order to make the change effective.
    Doing this will also guard against the (now ancient) AutoPlay virus, which could still be lurking somewhere on the net.

  • How can I set up lightroom 5 in my macbook, so that it becomes my default editing program, so that it starts up when I insert my sd card into the mac

    How can I set up lightroom 5, so that it becomes my main / default editing program & that when I insert my sd card into the mac lightroom starts instead of iPhoto .

    Thanks.  Im new to apple, which preference?
    Sent from my iPhone

  • I have powerpoint for Mac on my imac.  I can't seem to get the active text box function to work like it did on my PC.  How can I insert an active textbox into a presentation that will allow me to type while presenting?

    I have powerpoint for Mac on my imac.  I can't seem to get the active text box function to work like it did on my PC.  How can I insert an active textbox into a presentation that will allow me to type while presenting?

    I've gotten a little further on this. The dynamic select is
    working fine. It's the "a href" code that isn't. I'm wondering if
    someone can look at this line and tell me if it's okay to build the
    query string this way. The storeid comes through fine but I'm still
    not getting the employeeid value to pass. Here's line that's not
    working:
    td><a href="registerStoreCust.php?storeid=<?php echo
    $row_storeRS['storeid']; echo "&employeeid="; echo
    $_GET['employeeLM']; ?>">Register
    Customer</a></td>

  • Insert a single space into a NOT NULL column defined as CHAR(1)

    Hi,
    I am trying to run a C program in which I am inserting a space character into a database table, where the column has been defined as CHAR(1) NOT NULL.
    I am initialising a variable defined in C as: char, with a blank but after running the insert statement I get an error: ORA-01400: cannot insert NULL into �. .
    create table nullTest ( col1 char(1) NOT NULL );
    Sample code:
    EXEC SQL BEGIN DECLARE SECTION;
    char dbo_cValue;
    EXEC SQL END DECLARE SECTION;
    dbo_cValue = � �;
    EXEC SQL
    INSERT
    INTO nullTest
    col1
    VALUES
    :dbo_cValue
    My options are: char_map=charz, code=ANSI_C, mode=ANSI.
    I understand that if I was using char_map = VARCHA2, on input - if the input value contains nothing but blanks Oracle treats it like a null, but I am not using VARCHAR2 option, but CHARZ.
    I tried STRING and other options and I cannot get this to work.
    Is there a way where I can insert a space character into a table (using a C program), which has a constraint of �not null� while using C type variables?
    I would appreciated any help on this.
    Thank you.

    Since you did not post a sample of the code that produces an error, its hard to speculate what might be wrong with it.
    But, the following sample works, and successfully inserts a space into the table.
    #include <sys/types.h>
    #include <stdio.h>
    EXEC SQL INCLUDE SQLCA ;
    EXEC SQL BEGIN DECLARE SECTION ;
            VARCHAR col[10] ;
            char * uid ;
    EXEC SQL END DECLARE SECTION ;
    int main(void)
            uid = (char *)"/" ;
            EXEC SQL connect :uid ;
            printf("Connected to Oracle!\n") ;
            strcpy(col.arr, " ") ;
            col.len = strlen(col.arr) ;
            EXEC SQL insert into ins_null values (:col) ;
            EXEC SQL COMMIT WORK RELEASE ;
    }And, here is the table definition, and a select after running the above program once.
    SQL> create table ins_null(col varchar2(10) not null) ;
    Table created.
    SQL> select ':'||col||':' from ins_null ;
    ':'||COL||':
    1 row selected.
    SQL>

  • How to insert a image file into oracle database

    hi all
    can anyone guide me how to insert a image file into oracle database now
    i have created table using
    create table imagestore(image blob);
    but when inserting i totally lost don't know what to do how to write query to insert image file

    Hi I don't have time to explain really, I did have to do this a while ago though so I will post a code snippet. This is using the commons file upload framework.
    Firstly you need a multi part form data (if you are using a web page). If you are not using a web page ignore this bit.
    out.println("<form name=\"imgFrm\" method=\"post\" enctype=\"multipart/form-data\" action=\"FileUploadServlet?thisPageAction=reloaded\" onSubmit=\"return submitForm();\"><input type=\"FILE\" name=\"imgSource\" size='60' class='smalltext' onKeyPress='return stopUserInput();' onKeyUp='stopUserInput();' onKeyDown='stopUserInput();' onMouseDown='noMouseDown(event);'>");
    out.println("   <input type='submit' name='submit' value='Submit' class='smalltext'>");
    out.println("</form>"); Import this once you have the jar file:
    import org.apache.commons.fileupload.*;Now a method I wrote to upload the file. I am not saying that this is correct, or its the best way to do this. I am just saying it works for me.
    private boolean uploadFile(HttpServletRequest request, HttpSession session) throws Exception {
            boolean result = true;
            String fileName = null;
            byte fileData[] = null;
            String fileUploadError = null;
            String imageType = "";
            String error = "";
            DiskFileUpload fb = new DiskFileUpload();
            List fileItems = fb.parseRequest(request);
            Iterator it = fileItems.iterator();
            while(it.hasNext()){
                FileItem fileItem = (FileItem)it.next();
                if (!fileItem.isFormField()) {
                    fileName = fileItem.getName();
                    fileData = fileItem.get();
                    // Get the imageType from the filename extension
                    if (fileName != null) {
                        int dotPos = fileName.indexOf('.');
                        if (dotPos >= 0 && dotPos != fileName.length()-1) {
                            imageType = fileName.substring(dotPos+1).toLowerCase();
                            if (imageType.equals("jpg")) {
                                imageType = "jpeg";
            String filePath = request.getParameter("FILE_PATH");
            session.setAttribute("filePath", filePath);
            session.setAttribute("fileData", fileData);
            session.setAttribute("fileName", fileName);
            session.setAttribute("imageType", imageType);
            return result;  
         } And now finally the method to actually write the file to the database:
    private int writeImageFile(byte[] fileData, String fileName, String imageType, String mode, Integer signatureIDIn, HttpServletRequest request) throws Exception {
            //If the previous code found a file that can be uploaded then
            //save it into the database via a pstmt
            String sql = "";
            UtilDBquery udbq = getUser(request).connectToDatabase();
            Connection con = null;
            int signatureID = 0;
            PreparedStatement pstmt = null;
            try {
                udbq.setUsePreparedStatements(true);
                con = udbq.getPooledConnection();
                con.setAutoCommit(false);
                if((!mode.equals("U")) || (mode.equals("U") && signatureIDIn == 0)) {
                    sql = "SELECT SEQ_SIGNATURE_ID.nextval FROM DUAL";
                    pstmt = con.prepareStatement(sql);
                    ResultSet rs = pstmt.executeQuery();
                    while(rs.next()) {
                       signatureID = rs.getInt(1);
                    if (fileName != null && imageType != null) {
                        sql = "INSERT INTO T_SIGNATURE (SIGNATURE_ID, SIGNATURE) values (?,?)";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setInt(1, signatureID);
                        pstmt.setBinaryStream(2, is2, (int)(fileData.length));
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
                if(mode.equals("U") && signatureIDIn != 0) {
                    signatureID = signatureIDIn.intValue();
                    if (fileName != null && imageType != null) {
                        sql = "UPDATE T_SIGNATURE SET SIGNATURE = ? WHERE SIGNATURE_ID = ?";
                        InputStream is2 = new ByteArrayInputStream(fileData);
                        pstmt = con.prepareStatement(sql);
                        pstmt.setBinaryStream(1, is2, (int)(fileData.length));
                        pstmt.setInt(2, signatureID);
                        pstmt.executeUpdate();
                        pstmt.close();
                        con.commit();
                        con = null;
            } catch (Exception e) {
                con = null;
                throw new Exception(e.toString());
            return signatureID;
       }

  • How to insert a default value into MS server in java - help please

    hi
    suppose if i have a table and one of the column has a default value when the table was created. how can i insert the default value into this column? assuming that the column is the second column and i can't specify the column name when inserting. thanks.

    thanks for ur response, so if i have insert statement as follow
    insert into someTable values (1,'val1', 'val2', 'val3', 'val4')
    and column 3 has default value = DEFAULT
    then, to insert default value, my insert statement will look like this
    insert into someTable values (1,'val1', 'val3', 'val4')
    but the number of values will not match the number of columns.

  • Blue Screen of Death (B.S.O.D.) when inserting cd for import into ITunes...

    Hello All -
    I'm new to this forum. I'm so frustrated with Itunes crashing all of a sudden. It was running great for the first about 100 cds that I imported. I was running the latest version and abruptly started getting the B.S.O.D. the moment I inserted an audio cd into the drive and it began to load up for import. XP gives a quick blue screen and shuts everything down to the point of posting and restarting windows. Sometimes if I still have that cd in the drive, it will reboot once again and give the serious error (fatal error) once the desktop appears. I thought maybe the latest version had a glitch so I backed up to the version that came with my ipod 6.0.0.18 but I'm still getting the same problems. I even tried putting all of the mp3s stored so far in a different directory, wiping out the two itunes library files under my music folder and putting the new cds in the default my music\itunes directory but all of this and I'm getting the same problems all over again.
    The screen flashes too fast to allow me to read what the error is that is causing the crash. I'm at the point of saying Itunes for Windows totally *****. I'm new to the IPOD world and was so thrilled but I'm having nothing but problems with the importing.
    Anyone out there who is experiencing this problem or have any suggestions? I'm only about 1/3 of the way thru my music collection of over 500 cd's and need this program to work.
    Thanx in advance for any help!

    DJCHACHI -
    I found out the problem. I don't know if it will be the same for you though. I had a program installed on my computer called DVD Region Free which runs a program in the background called dvd43free.exe. Even if I don't have the program running, the dvd43free.exe file that is in the registry corrupts ITunes. Simply uninstall whatever program you may have to get rid of that stupid file dvd43free and this should fix it. I did this and now ITunes has not crashed a once since. I think there are different programs out there that use the file for backing up dvd's, not only dvdregionfree which I don't use anymore anyways so I uninstalled it. Hope this helps.

  • Can't insert a CD/DVD into the disc drive.  Recently installed a new harddrive, and the CD/DVD drive hardware is no longer recognized. Also, with new harddrive,  OS was updated from Snow Leopard to Mt. Lion 10.8.5 on late 2007 MBP.

    Can't insert a CD/DVD into the disc drive.  Recently installed a new 1 tb hard drive, and the CD/DVD drive hardware is no longer recognized. Also, with new hard drive,  OS was updated from Snow Leopard to Mt. Lion 10.8.5 on late 2007 MBP (2.2 GHZ Intel Core 2 Duo.  4 GB 667 MHZ DDR2 SDRAM)

    Also, when I check out the hardware list, under Disc Burning - the following is reported:  No disc burning device was found. If the device is external, make sure it’s connected and turned on.
    The disc drive worked fine prior to the HD upgrade and OS update to Mt. Lion.

Maybe you are looking for