JDBC Statement Profiling

Hi,
I have turned on JDBC Statement Profiling on my server. I can
get the statements being executed, but the Start & Stop times or
all Statements is the same. The relevant code and output follows.
Anybody see what I am doing wrong.
thanks,
Harish.
public static void printJDBCStatement(JDBCStatementProfile mb) {
System.out.println("\tStatement: " + mb.getStatementText());
System.out.println("\t\ttime = " + mb.getTimeTaken());
System.out.println("\t\tstarttime = " + mb.getStartTime());
System.out.println("\t\tendtime = " + mb.getStopTime());
System.out.println("\t\tthread = " + mb.getThreadId());
System.out.println("\t\tParams:");
int cnt = mb.getParameterCount();
for(int i=0; i<cnt;i++) {
System.out.println("\t\t\tParam " + (i+1) + mb.getParameter(i+1));
     Statements:
     Statement: INSERT INTO QUERY (ID, TYPE, OWNER, OBJVERSION) VALUES (?, ?, ?,
0)
          time = 0
          starttime = 1033591935157
          endtime = 1033591935157
          thread = Thread-15
          Params:
               Param 132397
               Param 212650
               Param 399999999
     Statement: SELECT OBJVERSION FROM QUERY WHERE ID = ? FOR UPDATE NOWAIT
          time = 0
          starttime = 1033591935167
          endtime = 1033591935167
          thread = Thread-15
          Params:
               Param 132397
     Statement: DELETE FROM SELECT_LIST WHERE QUERY_ID = ?
          time = 0
          starttime = 1033591935177
          endtime = 1033591935177
          thread = Thread-15
          Params:
               Param 132397
     Statement: SELECT 5, OBJVERSION, 0 FROM QUERY WHERE ID = ?
          time = 0
          starttime = 1033591935187
          endtime = 1033591935187
          thread = Thread-15
          Params:
               Param 132397

"Harish" <[email protected]> wrote in message
news:[email protected]..
>
I know for a fact that the statements take more than a 1ms.Could you try to run this code and tell what it prints?
public class test {
public static void main(String args[]) throws Throwable {
long previousTime = 0;
long currentTime = 0;
for (int i = 1; i < 1000000; i++) {
previousTime = System.currentTimeMillis();
// Thread.sleep(20);
currentTime = System.currentTimeMillis();
if (currentTime != previousTime) {
System.out.println("Difference: " + (currentTime - previousTime));
Regards,
SlavaImeshev
>
thanks,
Harish.
"Slava Imeshev" <[email protected]> wrote:
Hi Harish,
AFAIR this fact means that execution time is
less than 1ms. It's because java timer is not
very good at measuring precise periods of time.
So these digits are pretty good :)
Regards,
Slava Imeshev
"Harish" <[email protected]> wrote in message
news:3d9b6cfd$[email protected]..
Hi,
I have turned on JDBC Statement Profiling on my server. I can
get the statements being executed, but the Start & Stop times or
all Statements is the same. The relevant code and output follows.
Anybody see what I am doing wrong.
thanks,
Harish.
public static void printJDBCStatement(JDBCStatementProfile mb){>
Statements:
Statement: INSERT INTO QUERY (ID, TYPE, OWNER, OBJVERSION) VALUES
0)
time = 0
starttime = 1033591935157
endtime = 1033591935157
thread = Thread-15
Params:
Param 132397
Param 212650
Param 399999999
Statement: SELECT OBJVERSION FROM QUERY WHERE ID = ? FOR UPDATE NOWAIT
time = 0
starttime = 1033591935167
endtime = 1033591935167
thread = Thread-15
Params:
Param 132397
Statement: DELETE FROM SELECT_LIST WHERE QUERY_ID = ?
time = 0
starttime = 1033591935177
endtime = 1033591935177
thread = Thread-15
Params:
Param 132397
Statement: SELECT 5, OBJVERSION, 0 FROM QUERY WHERE ID = ?
time = 0
starttime = 1033591935187
endtime = 1033591935187
thread = Thread-15
Params:
Param 132397

Similar Messages

  • How to get the jdbc statement profile in 8.1

    the wls 8.1 api does not have the methods in the wls 7 api for jdbc statement profiling...
    in 7, the connection pool mbean has
    setSqlStmtProfilingEnabled()
    and the connection pool runtime mbean has
    getStatementProfiles(int index, int count)
    but in 8, i don't see these. i see the JDBCStatementProfile object in the api, but i don't see how to enable it or retrieve it.
    is this feature removed? or moved?
    thanks

    Thanks for your response. But I need Process ID
    not Product ID.
    GetCurrentProcessID
    Function should return you Process ID.
    Gaurav Khanna | Microsoft .NET MVP | Microsoft Community Contributor

  • How to insert an image file as blob using JDBC Statement

    Hi,
    I'm new on java.
    I want the code to insert an image file in Oracle database whose data type is blob.
    i want to use JDBC statement not the prepared statement.
    Please help me out.

    user8739226 wrote:
    thanks for the solution.
    I want to ask one thing
    let say i've created a method in a bean in which i'm passing three parameters.
    One is tablename as String, Second is Name of tablefields as Object, Third is Values as Object
    Like:
    public synchronized int insert(String table,Object[] fields, Object[] values)Ah now we're getting somewhere. I was trying to come up with a situation where using a regular Statement over PreparedStatement would be viable and came up with practically nothing.
    In the method body i'm accessing the table fields and values and combining them into the insert sql query.
    how can i do this using preparedstatment.
    how do i come to know here in this bean that this value is int or string or date at runtime to use setInt, setString, setdate or setBlob respectively.That's your problem. Bad design. You want to make some sort of universal insert method that can insert anything anywhere. But it doesn't really make sense, because whenever you're trying to insert something, you know exactly what you want to insert and where. You could use a PreparedStatement at that point (although encapsulate it in its own method). Now you're trying to create your own poorly designed framework over JDBC that doesn't solve problems, only increases them.
    Above was the only reason i saw, i was using statement instead of preparedstatment as statement was looking easy in this situation.
    please, give me the solution of above using preparedstatment.No, rather you should reconsider your design. What advantage does your insert() method give you over, let's say using a regular PreparedStatement. Granted, you can put your connection opening and other boilerplate code in the method. But if that's your only problem, then your insert method isn't gonna be much use. You could always switch to JPA for example and work with that.

  • What is the size limitation of Oracle JDBC Statement?

    Want to know how large is the limiation of one complete SQL insert string can be place
    into a JDBC Statement and can insert the big record successfully. I tried up to 13K, JDBC still can accept it. Does some experienced
    guru can tell me what is the size limitation
    for insert or update SQL string JDBC can accept it?
    Thanks a lot.

    None known. More than 10 GB. Please note Acrobat is not for server use (I mention that because you mention C# and experience shows it is often preferred for backend development).

  • Batching disparate JDBC statements

    I am trying to batch execute a bunch of JDBC statements which are disparate - ie. insert , update. Is there a way to do this via Oracle's Thin JDBC driver? Someone mentioned that it might be possible using Oracle JDBC Callable statement interface to bunch together a bunch of SQL statements(not stored procedures) - but i could not find any information on this.
    Thanks

    Seems like you are making it harder than it needs to be. What is wrong with JDBC batching or even Oracle Style batching?
    PreparedStatement psIns = con.prepareStatement( <some insert statement> );
    PreparedStatemetn psUpd = con.prepareStatement( <some update statement> );
    for ( int at = 0; at < numRecsToInserAndUpdate; ++at )
        psIns.setLong( 1, uids[at] );
        psIns.setBlah( 2, ... );
        psIns.addBatch();
        psUpd.setString( 1, updateStrings[at] );
        psUpd.addBatch();
    psIns.executeBatch();
    psUpd.executeBatch();The above example uses JDBC style batching, you can as easily do this with Oracle style batching.
    R.

  • Jdbc statement in case of an unknown database operation

    hi,
    in an application in java, which makes connection to the database using JDBC,
    if for eg, i am not sure if the statement is going to be a select or update or insert, which method of Statement i should be using. ?
    Thanx.

    try execute() method of java.sql.Statement object.
    hi,
    in an application in java, which makes connection to the database using JDBC,
    if for eg, i am not sure if the statement is going to be a select or update or insert, which method of Statement i should be using. ?
    Thanx.

  • WHAT'S GOING ON!!!? JDBC Statement Problems

    Sorry about the 2 previous posts, I kept getting an error when I tried to submit my thread saying that it could not be posted, but obviously it could!!
    Anyway can anyone help me? One of my JSP's refuses to execute properly so I presume there is something wrong with the associated methods in my connector.java file. Everytime I try and run my JSP in TomCat it produces the error message "java.sql.SQLException: java.sql.SQLException: General error, message from server: "Table 'talboothdb.roomsoccupied' doesn't exist". The MySQL statements I am using work fine when typed directly into MySQL via the Command Prompt so I know they arn't the problem. Can anyone see where I am going wrong?
    The neccessary connector java and the JSP I am using are displayed below,
    package javaclass;
    import java.sql.*;
    import java.util.*;
    public class connector{
      String error;
      Connection con;
      ResultSet rs = null;
      int success;
      public connector()   { }
      public void connect() throws ClassNotFoundException,
                               SQLException,
                               Exception {
           try
                Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                con = DriverManager.getConnection(
                     "jdbc:mysql://localhost:3306/talboothdb","","");
                } catch (ClassNotFoundException cnfe) {
                     error = "ClassNotFoundException: could not locate DB driver";
                     throw new ClassNotFoundException(error);
                } catch (SQLException cnfe) {
                     error = "SQL Exception: Could not connect to database.";
                     throw new SQLException(error);
                } catch (Exception e) {
                     error = "Exception: An unknown error occured while connecting to DB";
                     throw new Exception(error);
           public void disconnect() throws SQLException {
                try {
                     if ( con != null ) {
                          con.close();
                } catch (SQLException sqle) {
                     error = ("SQLException: unable to close the DB connection");
                     throw new SQLException(error);
    public void roomsBooked(String arrivalDate, String departureDate)
                                  throws SQLException, Exception {
                if (con != null) {
                  try {
                    PreparedStatement checkBookings;
                    checkBookings = con.prepareStatement
                         ( "CREATE TEMPORARY TABLE roomsoccupied "
                        + "SELECT roombooked.room_id FROM roombooked, booking "
                        + "WHERE "
                        + "roombooked.booking_id = booking.booking_id "
                        + "AND "
                        + "booking.arrival_date <  '?' "
                        + "AND "
                        + "booking.departure_date >  '?' "
                    checkBookings.setString(1, departureDate);
                    checkBookings.setString(2, arrivalDate);
                    checkBookings.executeUpdate();
                  } catch (SQLException sqle) {
                    error = ""+sqle;
                    throw new SQLException(error);
                } else {
                  error = "Exception: Connection to database was lost.";
                  throw new Exception(error);
         public ResultSet roomsAvailable()
                                  throws SQLException, Exception {
                if (con != null) {
                  try {
                    PreparedStatement checkAvailability;
                    checkAvailability = con.prepareStatement
                         ( "SELECT rooms.room_no FROM rooms "
                        + "LEFT JOIN roomsoccupied ON rooms.room_no=roomsoccupied.room_id "
                        + "WHERE roomsoccupied.room_id IS NULL;"
                    checkAvailability.executeQuery();
                  } catch (SQLException sqle) {
                    error = ""+sqle;
                    throw new SQLException(error);
                } else {
                  error = "Exception: Connection to database was lost.";
                  throw new Exception(error);
             return rs;
    <%@ page language="java"
        import="java.sql.*, java.io.*, java.util.*
         " errorPage="error.jsp" %>
    <jsp:useBean id="javaBean" class="javaclass.connector" />
    <html>
    <head></head>
    <body>
    <%
          javaBean.connect();
          String arrivalDate =  request.getParameter("ArrivalDate");
          String departureDate =  request.getParameter("DepartureDate");
          ResultSet rs = javaBean.roomsAvailable();
          while(rs.next())
          {  %> Room number <%= rs.getString(1) %>
           <P><% }
          javaBean.disconnect();
    %>
    </body>
    </html>

    Cross-posted every which way from Sunday:
    http://forum.java.sun.com/thread.jsp?thread=498755&forum=48&message=2355311
    http://forum.java.sun.com/thread.jsp?thread=498751&forum=54&message=2355294
    http://forum.java.sun.com/thread.jsp?thread=498747&forum=48&message=2355272
    http://forum.java.sun.com/thread.jsp?thread=498746&forum=48&message=2355270
    http://forum.java.sun.com/thread.jsp?thread=497689&forum=54&message=2350463
    bluey_the_punch, why are you so wedded to this CREATE TEMPORARY TABLE? In an earlier thread it was recommended that you see if this can be managed with a JOIN. Did you at least try it?
    I see you added PreparedStatement, but you didn't implement it correctly. You certainly don't need to put single quotes around the question marks in the SQL. I'd also recommend that you make those columns dates in your database and use setDate() to bind the values. Strings compare much differently than dates do. If you're not getting the expected results, that might be why.
    It just looks like you've blown off the advice you've gotten so far and just keep asking the same question in hope of getting the answer you want to hear. JMO - MOD

  • Logging JDBC Statements in Weblogic 8.1

    Hi,
    I am using Weblogic 8.1.I want to see the JDBC logs and right now I am getting
    "Oracle Jdbc tracing is not avaliable in a non-debug zip/jar file" error. Can
    any one help me with how to turn the JDBC Logging on? I am facing a wierd situation
    that one of my queries(it's from a Message Driven Bean) updates the Oracle database
    with junk values every time(the junk value differs each time) and so I want to
    see the exact SQL query which does this update.
    Thanks
    Jay

    Jay Balasubramanian wrote:
    Hi,
    I am using Weblogic 8.1.I want to see the JDBC logs and right now I am getting
    "Oracle Jdbc tracing is not avaliable in a non-debug zip/jar file" error. Can
    any one help me with how to turn the JDBC Logging on? I am facing a wierd situation
    that one of my queries(it's from a Message Driven Bean) updates the Oracle database
    with junk values every time(the junk value differs each time) and so I want to
    see the exact SQL query which does this update.
    Thanks
    JayHi. When we turn on jdbc logging, oracle's thin driver prints this out. There
    are two separate versions of the thin driver. We ship the regular one. The
    other one is a debug version. The best course is to download oracle's
    latest appropriate thin driver and put the debug version ahead of all weblogic
    jars in the classpath constructed for the server. Then when you turn on jdbc
    logging, you will get copious debug output.
    Joe

  • Rollback of JDBC Statement on error - Stored Procedure

    Hi All,
    We are using the JBDC receiver adapter for inserting the record and for that we are using the Strored Procedure and we have N number of the records for insertion in a single mapping so, we have given the occurence of the Statement 1 : unbounded as, multiple statement will be executed so, my query is if one of statement fails because of some error(Mapping error or data error) what will happen to the statement which are already executed, do they rollback? or it is not possible in case of stored procedure?
    Regards,
    Gaurav

    Hi,
    This is one of the solution but i guess there is one more issue, if we have 10 statements and third statement shows error and Stored Exception exception branch is able to catch then it will rollback the previous statement but can we able to restrict another 7 pending statement for execution or not?
    Regards,
    Gaurav

  • JDBC Statement Bug with OracleLite 4.0.1.2?

    I have found what appears to be a bug. Has anyone else encountered this bug. I have the following code:
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select columnA,columnB from tableA");
    while (rs.next())
    System.out.println("ColumnA="+rs.getString("ColumnA"));
    System.out.println("ColumnB="+rs.getString("ColumnB"));
    rs.close();
    rs = stmt.executeQuery("select column1, column2,column3 from Table1");
    while (rs.next())
    System.out.println("Column1="+rs.getString("Column1"));
    System.out.println("Column2="+rs.getString("Column2"));
    ("Column3="+rs.getString("Column3"));
    Column 3 is the problem. I get the
    following Exception:
    System.out.printlnjava.sql.SQLException: >>> [ODBC S1002] invalid column number
    After researching it I found that you
    cannot reuse a Statement object over and
    over again. The reason is that the first
    execution of a statement initializes the
    number of columns to be returned and each
    subsequent statement executed does not
    reinitialize the column count. So in the
    case above the column count is 2, and I
    issue a query with 3 columns using the
    same statement object, hence the bug.
    I know the work around, just wanted to
    know if this is a know bug.Any thoughts.
    Mike H.

    I've never heard of anything like this either. But I'm not sure I'm properly tracking what you say. You drop a PR file into the source well and it disappears? If you have a Finder window open and you drag it to the Batch window, you actually see the file deleted in the Finder window?
    Or do you mean that the PR file doesn't get copied to the well?
    Russ

  • Jdbc Statement hangs

    Folks ,
    I have writen some jdbc code and my applications hangs intermittently, we are using oracle database .
    Thanks,
    Manish

    Hi,
    What do you mean by "applications hangs intermittently"?
    But try to put following logic to figure out what is the time taken by jdbc sql query.
    a) get system time before the execution of sql query and store it in temp variable t1
    b) get system time after the execution of sql query and store it in temp variable t2
    c) Find out the difference and print it
    Once you are confident that SQL query is the one taking longer than expected time, check with Oracle experts in your org. for analyzing the log for the query and reasons for taking so much time
    regards,
    ganga

  • Jdbc-statement execute method

    in java documentation
    it is given
    ............., a single SQL statement may return multiple result sets and/or update counts. Normally you can ignore this unless you are (1) executing a stored procedure that you know may return multiple results or (2) you are dynamically executing an unknown SQL string.
    The execute method executes an SQL statement and indicates the form of the first result. You must then use the methods getResultSet or getUpdateCount to retrieve the result, and getMoreResults to move to any subsequent result(s).
    what is that procedure that return multiple result sets
    please some body clarify or place where i can get more details

    See if out parameters are used i can call CallableStatement's getter methods to retrieve value
    after execution .
    but the api is telling writing a dynamic procedure execution where procedure returns more than
    ResultSet(DQL) or updateCount(DML) . iam lokking for a procedure in oracle where this is possible

  • JDBC Statement.executeBatch() sometimes retrun NULL????

    WHY???? DataBase is ORACLE8.1.7
    i use PreparedStatement to executeBatch()
    and DatabaseMetaData.supportsBatchUpdates() = true
    but sometimes executeBatch() = NULL !!!!
    is this respect with ORACLE parameter?

    thanx for nobody's help.
    i solved problem. it is a synchronization problem.
    public synchronized void getTable(JTable theTable){
    try {
    String sql="SELECT ";
    stmt=connection.createStatement();
    rs=stmt.executeQuery(sql);
    displayRS(rs,theTable);
    stmt.close();
    catch (Exception e ) {
    e.printStackTrace();
    }

  • JDBInsight 2.1.03 (JDBC/J2EE Profiler) with 2.2 Trace-in-Time Preview

    We (JInspired) are currently starting to prepare for the next release of JDBInsight
    2.2 which is focused on transaction concurrency issues based on detailed tracing
    and timeline analysis. If anyone is interested we have an evaluation download
    of JDBInsight 2.1.03 which includes an very early preview of "Trace-in-Trace"
    that is the basis for the 2.2 release.
    I would appreciate any feedback in terms of feature set and performance load of
    the tracing. We hope to have the server side aspect finished this week and for
    the remaining weeks our focus is on the production of quality visualizations within
    the console.
    More Information:
    http://www.jinspired.com/products/jdbinsight/downloads/index.html
    Regards,
    William Louth
    JDBInsight Product Architect
    JInspired
    "Tune and Test with Insight"
    http://www.jinspired.com

    Seems to work for me.
    This is what I did.
    - Created a new project
    - Added a button
    - In the CSS file (resources/stylesheet.css) add the following
    .commandButton{
         color: red;
         font-weight: bold;
    }- In the button propertysheet clicked on StyleSheet
    property editor and entered "commandButton"
    - Refreshed the designer using "refresh" context menu
    Now in the designer the button immediatly changed to what specified in the CSS selector class .
    Have you refreshed designer using "refresh" context menu (BTW, in the next release this may not be required).
    - Winston

  • NullPointerException at com.mysql.jdbc.Statement.executeQuery

    hi,
    i use mysql, mm-mysql driver. In code, 4 different types of queries are present i use 4 kind of threads that retrive data from database (for each type of query) every 5 secs.Code sometimes works and sometimes throws null pointer exception.Although i used different result sets for each type of query, problem still remains. what can i do? what is the exact source of problem?
    thanx in advance
    hELin

    GuiSample.java :
    public class ThreadIncoming implements Runnable
    private boolean suspend; // Flag indicating that we should suspend the loop
    private Thread thread;
    public ThreadIncoming()
    start();
    public void start()
    thread = new Thread(this);
    suspend = false;
    thread.start();
    public void suspend()
    // Set the suspend flag - when the run loop comes back round it will check this and wait
    suspend = true;
    public synchronized void resume()
    // Unset the suspend flag - the call to notify will wake up the waiting Thread which will then continue
    suspend = false;
    notify();
    public void stop()
    thread = null;
    resume(); // Call resume in case stop is called while waiting
    public void run()
    if (queryApp != null && queryApp.isConnected() ) {
    while(Thread.currentThread() == thread) {
    if (filterIncomingRuns)
    suspend();
    if(suspend) {
    // Check whether the suspend flag is set - get the current Thread to wait if it is
    synchronized(this)
    while(suspend) {
    try {
    wait();
    catch (Exception e1) {
    e1.printStackTrace();
    try
    fillAlarmTable();
    Thread.sleep(5000);
    catch(InterruptedException e)
    private void fillAlarmTable() {
    queryApp.getTable(logAlarmTable);
    ...//END OF GuiSample.java
    In this class, the thread type used is above shown. Every thread's task is to retrive data from DB and insert it into jtable's in GuiSample.java...
    QueryDB.java: where DB operation are done
    getTable(jtable theTable) {
    stmt = connection.createStatement();
    if (theTable.getModel().getClass().getName().equals("LogAlarmTableModel")) {
    rsAlarm = stmt.executeQuery(sql);
    displayRS(rsAlarm,theTable);
    else if ....
    stmt.close();
    i tried to write some part of the code..waiting for ur advice. thanx
    hELin

Maybe you are looking for

  • Loading error

    Hi, I'm trying to load data it is given an error, WRT_8025 Error in BW Target. [Number of fields in Target do not Match Repository fields = 15 BW fields = 18] WRITER_1_*_1> Wed Oct 19 15:07:55 2007 WRITER_1_*_1> WRT_8025 Error in BW Target. [===> Com

  • Authority check on company code

    Hi ,       How i need to check whether the company codes in an internal table is having creation access to the particular user or not ?.      In authority check what is  ACTVT - 01,02,03  signifies ?? Thanks in adv. varma

  • Oracle restart and ASM

    Hi, I have noticed following 'strange' behaviour of Oracle Restart and ASM. starting position: -bash-3.2 $ crsctl status resource -t NAME           TARGET  STATE        SERVER                   STATE_DETAILS Local Resources ora.DATA.dg               

  • Variable array names...i think

    I have a list of arrays which need filling and i have created a for lop that will run the necessary commands to fill the arrays... how do i put an array name into the 'for' loop that will change each time... ie. for(int x = 0; x < 3; x++)     array ?

  • 11g Install Failure, Listener Error.

    11g Install Failure, Listener. ORA-12514: TNS:listener does not currently know of service requested in connect descriptor. I am attempting to install 11g, 11.1.0 onto a stand alone box which has Windows XP SP2 as the OS. The box is at present not net