ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » JavaCompute Node jdbc not recognising database delete row

Post new topic  Reply to topic
 JavaCompute Node jdbc not recognising database delete row « View previous topic :: View next topic » 
Author Message
kayhansefat
PostPosted: Fri Mar 23, 2007 3:45 am    Post subject: JavaCompute Node jdbc not recognising database delete row Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

Within a JavaCompute Node the only way I have managed to connect to DB2 UDB v8 on the same machine has been via the db2 jdbc drivers.

I have the following code:

Code:
public void getAlreadySentLetters()
    {
      try
      {
         Class.forName("com.ibm.db2.jcc.DB2Driver");
         Connection db2Conn = DriverManager.getConnection("jdbc:db2:LETTERDB","wbiadmin","wbiadminpass");
         Statement st = db2Conn.createStatement();
         String query = "SELECT * FROM GPSENT_LETTERS";
         ResultSet resultSet = st.executeQuery(query);
         
         while (resultSet.next())
         {
            String dbType = resultSet.getString("LETTER_ECAMISID");
            alreadySentLetters.add(dbType.trim());
         }
         
         resultSet.close();
         st.close();
         db2Conn.close();
      }
      catch (ClassNotFoundException e)
      {
         addToLog("In getAlreadySentLetters() method","ClassNotFoundException");
      }
      catch (SQLException sqle)
      {
         addToLog("In getAlreadySentLetters() method","SQLException: " + sqle);
      }
    }


The /var/mqsi/odbc/.odbc.ini file consists of:

Code:
LETTERDB=IBM DB2 ODBC Driver

[ODBC]
Trace=0
TraceFile=/var/mqsi/odbc/odbctrace.out
TraceDll=/opt/mqsi/merant/lib/odbctrac.so
InstallDir=/opt/mqsi/merant
UseCursorLib=0
IANAAppCodePage=4

[LETTERDB]
Driver=/opt/IBM/db2/v8.1/lib/libdb2.so
Description=LETTERDB Broker Database
Database=LETTERDB


Now the code works fine (alreadySentLetters is a Vector by the way to store the LETTER_ECAMISID's).

With no records in the table it works fine. When records are added into the table it picks them up - fine. But when a row is deleted from the table it doesn't seem to register and pics it up as still being in there.

It works if I redeploy the flow, but that obviously isn't ideal.

Now is it how the jdbc drivers are working? Should I include a line of code that 'refreshes' the rows in the table to get the latest? Or should I do it a completely different way?! Thanks
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Fri Mar 23, 2007 4:03 am    Post subject: Re: JavaCompute Node jdbc not recognising database delete ro Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

It is strange.

Sorry for his stupid questions.

Are you sure that you remove record form database JAVACompute is connected to ?
Are you sure that you remove this record ?
Are you sure that after removing this record this code is executed again ?
Maybe you red old logs.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
jefflowrey
PostPosted: Fri Mar 23, 2007 4:03 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Maybe the deletes haven't been committed by the time you're looking at the table.

Maybe you have locks on the tables that are preventing the deletes from completing until the locks are released.

You can use MbSQLStatement to access any Broker ODBC datasource.

Also, you can only really use the type 4 JDBC drivers from a JavaCompute node.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
marcin.kasinski
PostPosted: Fri Mar 23, 2007 4:10 am    Post subject: Reply with quote

Sentinel

Joined: 21 Dec 2004
Posts: 850
Location: Poland / Warsaw

jefflowrey wrote:
Maybe the deletes haven't been committed by the time you're looking at the table.



I forgot about this question.
This is common mistake.
_________________
Marcin
Back to top
View user's profile Send private message Visit poster's website
kayhansefat
PostPosted: Fri Mar 23, 2007 4:23 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

marcin.kasinski:

--Yes I am sure it is the same Database that the JCN is connected to.
--I removed the record manually in the DB2 Control Center, so yes.
--Yes the code/flow is executed again as it is triggered by an MQInput which I am sure receives a message
--I know it is a new addition to the log as the last modified time is updated to the log, and also I write the date and time to the log when I write to it.

jefflowrey:

--I am deleting the row via the db2cc and press the commit button, so pretty sure. I then check the table again via the db2cc and the row is deleted. I re-trigger the flow afterwards and it behaves like I described.

--I haven't heard of the MbSQLStatement before so might give that a try, any links?

--I did read up on the type 4 drivers but wasnt sure which 'type' I am using. Any links/examples of how to use the type 4 JDBC drivers in the JCN?

Thanks guys.[/quote]
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri Mar 23, 2007 4:38 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

The DB2 information center has good discussion on how to make sure you use the Type 4 driver. It's mainly a matter of what kind of url you specify.

MbSQLStatement is a class in the Java API for Message Broker - useable from JCNs - like MbElement, MbAssembly, MbService, etc.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kayhansefat
PostPosted: Mon Mar 26, 2007 4:10 am    Post subject: Reply with quote

Acolyte

Joined: 18 Oct 2006
Posts: 65

Ok thanks. I am having problems with using the MbSQLStatement class but I will create a new topic for this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » JavaCompute Node jdbc not recognising database delete row
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.