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 » DB2 Connection Using Java Compute node

Post new topic  Reply to topic Goto page 1, 2  Next
 DB2 Connection Using Java Compute node « View previous topic :: View next topic » 
Author Message
alerajeshh
PostPosted: Fri Sep 20, 2013 6:44 am    Post subject: DB2 Connection Using Java Compute node Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Hi am trying to connect to DB2 database using java compute node

Here is the code:
Code:
Connection conn;
                conn = java.sql.DriverManager.getConnection("jdbc:db2://host:port/sfglab:user=xxxx;password=xxxxx", "xxxx","xxxx");
               Statement st = conn.createStatement();
               String query="INSERT INTO MyDB.WMBADMIN.HOSPITAL_TIME(HOSPITAL,TIME) VALUES('"+hospital+"','"+time+"')";
               st.executeQuery(query);
            } catch (ClassNotFoundException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            } catch (SQLException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }



there is an SQLException :com.ibm.db2.jcc.am.SqlSyntaxErrorException: [jcc][10214][10050][3.66.46] java.util.Properties object passed to java.sql.Driver.connect() cannot be overridden by URL:
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 6:51 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

You are missing your ResultSet parms in your createStatement. See getConnection
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 7:02 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

ya ,i can understand from the error that there is something overriden..
How to solve that....please guide me...
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 7:05 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

alerajeshh wrote:
ya ,i can understand from the error that there is something overriden..
How to solve that....please guide me...


Have you read this InfoCentre article and have you followed exactly these steps ?

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fah61310_.htm
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 7:11 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

lancelotlinc wrote:
alerajeshh wrote:
ya ,i can understand from the error that there is something overriden..
How to solve that....please guide me...


Have you read this InfoCentre article and have you followed exactly these steps ?

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fah61310_.htm


yes i have done the same steps...creating a configurable service ...
restarting the broker.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 7:13 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

And then you use this code :



Code:
try {
        // Obtain a java.sql.Connection using a JDBC Type4 datasource - in this example for a
        // JDBC broker configurable service called "MyDB2" 

        Connection conn = getJDBCType4Connection("MyDB2",
                     JDBC_TransactionType.MB_TRANSACTION_AUTO);

        // Example of using the Connection to create a java.sql.Statement 
        Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                     ResultSet.CONCUR_READ_ONLY);
        ResultSet srs0 = stmt.executeQuery("SELECT NAME, CITY FROM MySchema.MyTable");   

        stmt.executeUpdate("UPDATE MySchema.MyTable SET CITY = \"Springfield\" WHERE Name = \"Bart\"");
        .
        // Perform other database updates   
        .

      } catch (SQLException sqx ){
        sqx.printStackTrace();
      } finally {
        // Clear the outMessage
        outMessage.clearMessage();
      }   

_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 7:17 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Damn...I forgot that am overriding the connection by passing the URL again...i cleared that... using this snippet
Connection conn = getJDBCType4Connection("MyDB", JDBC_TransactionType.MB_TRANSACTION_AUTO);

but u know master..there is one more exception

MbDatabaseException
com.ibm.broker.plugin.MbDatabaseException class:com.ibm.broker.jdbctype4.jdbcdbasemgr.JDBCType4Connection@2c849d4c method:JDBCType4Connection::createXAConnection source:BIPmsgs key:6233
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 7:24 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

alerajeshh wrote:
Damn...I forgot that am overriding the connection by passing the URL again...i cleared that... using this snippet
Connection conn = getJDBCType4Connection("MyDB", JDBC_TransactionType.MB_TRANSACTION_AUTO);

but u know master..there is one more exception

MbDatabaseException
com.ibm.broker.plugin.MbDatabaseException class:com.ibm.broker.jdbctype4.jdbcdbasemgr.JDBCType4Connection@2c849d4c method:JDBCType4Connection::createXAConnection source:BIPmsgs key:6233


How will you solve this problem ?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 7:26 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

As per the BIP6233 explains..there must be something wrong in URL.

but it is correct (URL)..

suggest me...
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Sep 20, 2013 7:31 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

No, the URL is almost certainly wrong.

You almost certainly hand-edited the connectionURLFormat parameter of the configurable service, instead of merely setting the relevant replacement properties.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 7:32 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

alerajeshh wrote:
suggest me...


Abandon your code (temporarily) and use the source code example exactly as presented from the InfoCentre to prove to yourself that you actually have a good configuration.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 7:50 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

error message: [jcc][t4][2057][11264][3.66.46] The application server rejected establishment of the connection.
An attempt was made to access a database, MyDB, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004


MyDB is the COnfigurableService ,that i created.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Sep 20, 2013 7:53 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

alerajeshh wrote:
error message: [jcc][t4][2057][11264][3.66.46] The application server rejected establishment of the connection.
An attempt was made to access a database, MyDB, which was either not found or does not support transactions. ERRORCODE=-4499, SQLSTATE=08004


MyDB is the COnfigurableService ,that i created.


Explicitly following the instructions in the working example sample cited will produce successful results.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
alerajeshh
PostPosted: Fri Sep 20, 2013 8:00 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Hurrayy,.....Thank you master...

I know this ..but am forgetting everything...

you know the configurable service name should be the database name...
Back to top
View user's profile Send private message
alerajeshh
PostPosted: Fri Sep 20, 2013 8:05 am    Post subject: Reply with quote

Acolyte

Joined: 19 Aug 2013
Posts: 55

Yes...Problem solved by this....http://www-01.ibm.com/support/docview.wss?uid=swg21443723

but figuring it out with insert statement.


can we insert data into tables...

do we need result set for that....
can u help me with stmts ..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » DB2 Connection Using Java Compute node
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.