cachedRowSet SQLException

Hey all,

I know i have asked this question in this forum before but i kinda of need a soultion so though i would see if some fresh eyes would know.


I am using a cachedRowSet

And I am just wondering when I execute an acceptChanges(con) command that causes a jdbc error to occur e.g insert nulls into columns that don’t allow nulls.

Is there any way to get the jdbc error message?

I get this exception printed to the command line by the cachedRowSetImp

java.sql.SQLException: Cannot insert the value NULL into column ‘ratio’, table 'Tuning.dbo.PROPERTY'; column does not allow nulls. INSERT fails.

And this exception thrown

javax.sql.rowset.spi.SyncProviderException: 5 conflicts while synchronizing

I really want to catch the first exception or at least be able to get the errorCode /error message

Does anyone know if is/is not possible to get this error because from what I have seen it is not possible



if there is no soultion which i assume there isn't as i have looked. I am wondering if another imp of cached row set would be ok

anyone have any other impl of cachedRowSet that they know works?


I am using Suns java 5 update 6 version
LVL 2
dboyd6868Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Giant2Commented:
using the try catch block you can take the exception.
Giant2Commented:
I think your error is given out when you use:
crs.updateRow()

encapsulate is in a try catch block like following:
try{
crs.updateRow();
}catch (Exception ex){
//in ex object there are all information about the exception.
}

Hope this could help you.
Bye, Giant.
Giant2Commented:
P.S. even with crs.InsertRow() method.
Starting with Angular 5

Learn the essential features and functions of the popular JavaScript framework for building mobile, desktop and web applications.

dboyd6868Author Commented:
Problem is it doesn't work like that there is no exception details

this is my code

public void updateChanges()throws SQLException,SyncProviderException
{
  Connection con = null;
  try
    {
      con =  BeanFactory.getConnectionFactory().createConnection();              
      super.acceptChanges(con);
      super.execute();
      con.close();
        
    }
    catch (SQLException e)
    {
      System.out.println("ERROR");
      e.printStackTrace();
      con.close();
      super.execute();
      throw e;                        
    }
    catch(Exception ej)
    {            
        System.out.println("ERROR2");
    }
            

 }

this is the stack trace i want to try to get the first SQLException that cachedRowSet seems to print the stacktrace of but not throw it


java.sql.SQLException: Cannot insert the value NULL into column 'altModulusOfElasticity', table 'Tuning.dbo.PROPERTY'; column does not allow nulls. INSERT fails.
      at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:365)
      at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2781)
      at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2224)
      at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:628)
      at net.sourceforge.jtds.jdbc.JtdsStatement.processResults(JtdsStatement.java:525)
      at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQL(JtdsStatement.java:487)
      at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeUpdate(JtdsPreparedStatement.java:421)
      at com.sun.rowset.internal.CachedRowSetWriter.updateOriginalRow(CachedRowSetWriter.java:693)
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:331)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:919)
      at com.indauto.util.IASCachedRowSet.updateChanges(IASCachedRowSet.java:59)
      at materialGradeMaintenance.MaterialPropertyData.saveMaterialProperty(MaterialPropertyData.java:315)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
      at javax.faces.component.UICommand.broadcast(UICommand.java:312)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:55)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)


//SQL EXCEPTION CAUGHT
ERROR
javax.sql.rowset.spi.SyncProviderException: 4 conflicts while synchronizing
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:382)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:919)
      at com.indauto.util.IASCachedRowSet.updateChanges(IASCachedRowSet.java:59)
      at materialGradeMaintenance.MaterialPropertyData.saveMaterialProperty(MaterialPropertyData.java:315)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
      at javax.faces.component.UICommand.broadcast(UICommand.java:312)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:55)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
javax.sql.rowset.spi.SyncProviderException: 4 conflicts while synchronizing
      at com.sun.rowset.internal.CachedRowSetWriter.writeData(CachedRowSetWriter.java:382)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:859)
      at com.sun.rowset.CachedRowSetImpl.acceptChanges(CachedRowSetImpl.java:919)
      at com.indauto.util.IASCachedRowSet.updateChanges(IASCachedRowSet.java:59)
      at materialGradeMaintenance.MaterialPropertyData.saveMaterialProperty(MaterialPropertyData.java:315)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:585)
      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
      at javax.faces.component.UICommand.broadcast(UICommand.java:312)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.ajaxanywhere.AAFilter.doFilter(AAFilter.java:55)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Thread.java:595)
dboyd6868Author Commented:
that method i have is a method in a class i have that extends CachedRowSetImpl (just needed some extra features the standard imp doens't have)
Giant2Commented:
you put this code in a try catch block.
    con =  BeanFactory.getConnectionFactory().createConnection();            
      super.acceptChanges(con);
      super.execute();
      con.close();

in the super class methods you call (acceptChanges(con) and execute()) are there try catch block?
dboyd6868Author Commented:
the super class is the java  CachedRowSetImpl  (which is the implementaion of the CachedRowSet

i.e no source no idea.


the only reason i extended it is that CachedRowSet does not define behaviour for the rowSet method getRowCount()
i just needed to implement this method thats all
Giant2Commented:
You can see where is the message catched taking the .class you suspect and decompile it.
In this manner you can see the method generate the exception and you can extends only that.
Giant2Commented:
>method getRowCount()
there is the size() method.

int size() Returns the number of rows in this CachedRowSet object.

Returns:
number of rows in the rowset
dboyd6868Author Commented:
already decompiled it but the code i get is somewhat funky i.e it wont recompile

i ddint see the excpetion stored anywhere and the method is the writeData() which is the main method for saving information if i want to extend this i may as well write my own rowSetWriter class

seems silly and if the code was easy to follow i could understand it but it uses some interesting no document java features
Giant2Commented:
>the method is the writeData()
In the code you decompiled do you have seen something about debugging? (debug on/off)
ex_01Commented:
nah no debug options

its the CachedRowSet writer class ( writeData() ) that i think the problem occurs in but if you decompile that class there seems to be alot of jibberish there no sure if its my decompiler cavaj
dboyd6868Author Commented:
sorry college had their account loged in on this machine above post was mine
Giant2Commented:
So in the writeData() method you see something like:
try{
}catch Exception e{
e.printStackTrace();
}


?
dboyd6868Author Commented:
actually i see some crazy code ( it doesn't recompile after it is decompiled )
it is something like this (note this is the only printStackTrace() in the code from CachedRowSetWriter

 private boolean updateOriginalRow(CachedRowSet cachedrowset)
        throws SQLException
    {
          //other code +        
                   
        k = preparedstatement1.executeUpdate();
        return false;
        return true;
        SQLException sqlexception;
        sqlexception;
        sqlexception.printStackTrace();
        crsResolve.moveToInsertRow();
        for(int l = 1; l <= callerColumnCount; l++)
        {
            crsResolve.updateNull(l);
        }

        crsResolve.insertRow();
        crsResolve.moveToCurrentRow();
        return true;
    }
Giant2Commented:
It seems not good decompiled.
When you decompile the class you add the full package in the decompiler classpath? In this manner you decompile correctly the class and after you can recompile.
        k = preparedstatement1.executeUpdate();//OK
        return false;//???
        return true;//???
        SQLException sqlexception;//OK
        sqlexception;//???

From the code you posted it's clear the decompiler didn't a correct decompiling.
I try to find the class you say (CachedRowSetWriter) and see what my decompiler told.
Giant2Commented:
Yes.
It's really really different.
Try to use this decompiler:
DJ Java Decompiler 3.9.9.91
available at:
http://members.fortunecity.com/neshkov/dj.html#New39

It can help you decompiling correctly.

Bye, Giant.
Giant2Commented:
I give suggestion about debugging, so an accept could be given, but dboyd6868 please tell us if you solved.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dboyd6868Author Commented:
never found a soultion,

actually found out this is a bug in the implementaion but could never get it correctly decompiled found workarounds for my application.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.