| Author | 
		  Message
		 | 
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 6:44 am    Post subject: DB2 Connection Using Java Compute node | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 6:51 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:02 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Knight
 
 Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:11 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Acolyte
 
 Joined: 19 Aug 2013 Posts: 55
  
  | 
		  
		    
			  
				
 
 
yes i have done the same steps...creating a configurable service ...
 
restarting the broker. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:13 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:17 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:24 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:26 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:31 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:32 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:50 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | lancelotlinc | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 7:53 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 8:00 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | alerajeshh | 
		  
		    
			  
				 Posted: Fri Sep 20, 2013 8:05 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |