Category: Java

JPA: How to resolve the “java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch” error in Java/JEE/JPA

I was developing a JPA JEE application were this strange and vague error appeared and stopped me from storing OrderHeader/OrderItem POJO’s.

Internal Exception: java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch.

This SDU error is rather vague and does not reveal the true problem in the executed SQL or Schema or constraint violation!
After many trials, here is the way I was able to identify the real Oracle DB error !

  1. Take the OrderHeader/OrderItems classes into a new JSE batch project.
  2. in NB , right-click –> insert code–> Persist EntityClass
  3. Add the following properties to “persistence.xml” for more detailed logging:
<properties>
 <property name="toplink.logging.level" value="FINEST"/>
 <property name="eclipselink.logging.parameters" value="true"/>
 </properties>

After the previous update you should be able to see in the Glassfish logs, all the executed SQL’s and even their bind variables.

<pre>Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Io exception: Size Data Unit (SDU) mismatch
Error Code: 17002
Call: INSERT INTO XYZ (x , y, z) values (?,?,?)
 bind => [655, 5, 62]
Query: InsertObjectQuery(zyx.entity.TocOrderItem[ ])
 at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:340)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1605)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:893)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:957)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:630)
 at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:558)
 at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1995)
...
Caused by: oracle.net.ns.NetException: Size Data Unit (SDU) mismatch
at oracle.net.ns.Packet.receive(Packet.java:264)
at oracle.net.ns.DataPacket.receive(DataPacket.java:92)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:588)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:953)
... 97 more

And now run the new batch project and you will see the (ORA-) error clearly.  Mine was related to some XMLType / Oracle Fields in the records I want to save (out of scope).

The problem as it seems to be : that the EJB Container shields and wraps some of the returned error codes and connections; this produces the vague SDU error. The solution uses the good-old-normal JSE not JEE  JVM which will allow a more interaction between your program and JDBC.

Some quick and easy examples into oracle XML DB.

Oracle XML DB is the API of SQL functions inside the oracle DBMS which makes oracle XML enabled.

If you don’t know much about XML, please refer to this quick tutorial :  especially the starting slide 74 discussing Oracle and XML.

XML DB is a series of SQL functions ,PL/SQL packages and DBMS features for processing XML data In and out of Oracle.

The most important feature; is adding the new column type “XMLType”; which enable storing structured and unstructured XML documents into oracle. A considerable step ahead from CLOB.

There are two sets of features :

Read more »

IBM Developer Works Days 2012.

IBM Developer Works Days 2012.
14 -15 Nov 2012

General Trends in Development

  • The term “GUI” is promoted to “User Experience” !
  • IDE’s and Technologies are trying to prove all the time that they are Agile oriented.
  • Applications Should be seen as a Service not a product.
  • Domain Specific Languages (DSL) are languages meant for non-developer application users to be able to perform activities on the system without developer involvement. I see it as one step forward from API’s but for users not developers. (just like how SQL was meant to be for databases).
  • Mixed Environments , more that one technology (or programming language) in one application to provide a service.
  • Mobile development is gaining ground and attention for accessing mobile B2C and B2B.
  • Office-Automation using mobile applications for the corporate employees.
  • BIG Data.
  • There is still a lot of work for developers to do.

Read more »

JAVA : Statistics Class

Another name for it would be Counter class.

How many times you did this ?

int databaseUpdateCounter=0;
.
{
.
     databaseUpdateCounter++;
.
}
.
.
System.out.println( "databaseUpdateCounter"+ databaseUpdateCounter);

you only need to follow up on the count of a certain operation.

And then you needed to count something else, and kept on adding counterVariables ?!

Read more »

The Enterprise applications of the future.

I had the privilege to attend JAZOON software development conference in Zurich. I heard a lot of buzzwords and  jargon there about the new technologies of the software development. from the group of seminars and keynotes there I generated a picture about the perfect Enterprise application in the future. In this article I try to paint this picture.

Read more »