var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Communication between JAVA and DB2 HowTo?
Hello, i am new to Java and DB2. If my posting is just too stupid, please dont laugh that loud.
There is my PC with a JAVA-application
There is another PC running a DB2.
Both PCs stand in different buildings, connected via VPN.
An IBM DB2 client runs on my PC.
The JAVA-application ist connected to the DB2, i can send SQL-queries and receive results.
Everything fine until now...
The Problem is:
I want to send other commands to the DB2 like "get snapshot for all on ds2"
But that doesnt work!
Here is my code:
I get this error: "com.ibm.db2.jcc.b.SqlException: [jcc][3.50.152] Die Methode executeQuery kann nicht zur Aktualisierung verwendet werden. ERRORCODE=-4476, SQLSTATE=null
Connection con = null;
con = DriverManager.getConnection( "jdbc:db2:DS2", "**username**", "**password**" );
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( "get snapshot for all on ds2" );
This is german. It means "you cant update with executeQuery"...
BUT: I dont update my Database. I just want to read some Monitor-datas...
Help! How to read monitor-data from DS2?
You cannot run db2 commands using jdbc. What db2 version and OS are you using?
My PC is Windows XP.
The other PC running DB2 is Linux. DB2 Version 188.8.131.528
You can use jdbc to query the admin views and functions and that will get you the snapshot info.
Visit the new-look
, register to gain access to the excellent content.
I will search, which admin view contains the required information.
But does this work for ALTER TABLESPACE too?
I want to change some DB2-Parameters like prefetchsize.
I believe that ALTERTABLESPACE is regulare SQL and can be executed through jdbc. To change parameters, look at the ADMIN_CMD stored Procedure.
thank you! I wil try that.
meanwhile i could get the required Information by query an admin view. That worked fine. example:
ResultSet rs = stmt.executeQuery( "SELECT sum(PREFETCH_WAIT_TIME) AS TIME FROM SYSIBMADM.SNAPAPPL" );
...to query the current PREFETCH_WAIT_TIME...
To change Prefetchsize, do this:
int rs = stmt.executeUpdate( "ALTER TABLESPACE USERSPACE1 PREFETCHSIZE 128" );
executeUpdate instead executeQuery
Just, if someone else has the same problems!