| |

VerySource

 Forgot password?
 Register
Search
View: 1034|Reply: 5

Urgent, everybody help out. Use jdbc connection to write blob to oracle successfully, but it won’t work if it is repla

[Copy link]

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-14 12:00:01
| Show all posts |Read mode
Use jdbc to connect to write blob to oracle successfully, but it won’t work if you change to jndi

Prompt to roll back, multiple settings setAutoCommit (true/false) will not work, check a lot of information can not be resolved, please help
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-10-14 16:30:01
| Show all posts
If it is a WebLogic server, pay attention to the writing of Blob to determine which implementation class is for special processing.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Japan

Post time: 2020-10-14 16:45:01
| Show all posts
Heavyweight servers treat Blobs, and Clobs have their own characteristics
Therefore, at this time, there will be differences between the JDBC and JNDI database operations, and it does not matter if the database is exported
The next section of Coding hopes to help you

    //Get database connection through JNDI
    Context context = new InitialContext();
    ds = (DataSource) context.lookup("ORA_JNDI");
    Connection con = ds.getConnection();
    con.setAutoCommit(false);
    Statement st = con.createStatement();
    //Insert an empty object empty_clob()
    st.executeUpdate("insert into TESTCLOB (ID, NAME, CLOBATTR) values ​​(1, "thename", empty_clob())");
    //Lock the data row for update, pay attention to the "for update" statement
    ResultSet rs = st.executeQuery("select CLOBATTR from TESTCLOB where ID=1 for update");
    if (rs.next())
    {
        //Forcibly convert to weblogic.jdbc.vendor.oracle.OracleThinClob after obtaining the java.sql.Clob object (different App Server may correspond to different)
        weblogic.jdbc.vendor.oracle.OracleThinClob clob = (weblogic.jdbc.vendor.oracle.OracleThinClob) rs.getClob("CLOBATTR");
        Writer outStream = clob.getCharacterOutputStream();
        //data is the incoming string, definition: String data
        char[] c = data.toCharArray();
        outStream.write(c, 0, c.length);
    }
    outStream.flush();
    outStream.close();
    con.commit();
    con.close();
Reply

Use magic Report

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-10-14 17:45:01
| Show all posts
Nothing else is wrong, I basically did this, the key is
//Forcibly convert to weblogic.jdbc.vendor.oracle.OracleThinClob after obtaining the java.sql.Clob object (different App Server may correspond to different)
        weblogic.jdbc.vendor.oracle.OracleThinClob clob = (weblogic.jdbc.vendor.oracle.OracleThinClob) rs.getClob("CLOBATTR");

In this sentence, weblogic.jdbc.vendor.oracle.OracleThinClob I can't find a similar class in WebSphere and cannot be replaced. I am stuck here because I must use WebSphere
Reply

Use magic Report

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-10-14 18:00:01
| Show all posts
Is there a problem with WebSphere POOL? If there is a problem, add WebLogic's weblogic.jar to the CLASSPATH
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-10-14 20:45:01
| Show all posts
That weblogic has 48M, which is too big, is there any convenient way?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list