Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Anyway to turn the JDBC log on

1 view
Skip to first unread message

Vineet Bhatia

unread,
Feb 5, 2002, 2:51:34 PM2/5/02
to
Hi,

Is there any way I can get a JDBC log through the DriverManager??

I tried doing the DriverManager.setLogStream(). That does'nt give me enough
information about cursor open, fetch and close??

- vineet


Joe Weinstein

unread,
Feb 5, 2002, 3:45:07 PM2/5/02
to Vineet Bhatia

Vineet Bhatia wrote:

That's all you're going to get. All the DriverManager does is to store the log stream.
It is the driver's responsibiliity to get the log stream and print out what it sees fit.
Some drivers are very chatty with the log, and others are more taciturn. Unless
there is a documented option for more/different debug output with this driver,
you will have to work with what you get now...

Joe Weinstein at B.E.A.


Vineet Bhatia

unread,
Feb 5, 2002, 7:26:45 PM2/5/02
to
:-(
For developers, it would be real nice thing to have.
Thanks Joe.

- vineet

"Joe Weinstein" <j...@bea.com> wrote in message
news:3C604453...@bea.com...

Sridhar Paladugu[CompCon tech]

unread,
Feb 7, 2002, 4:54:39 PM2/7/02
to
Try to use spy Trace utility.
For example
jdbc:spy:{jdbc:microsoft:sqlserver://<hostname>:1433;user=user;password=pass
word}; log=(file) c:\temp\spy.log;linelimit=80

in your connection statement. This will help you a bit more in tracing SQL
statements.
log all the JDBC activity in the c:\temp\spy.log file
Best of Luck.

Sridhar Paladugu
Microsoft Developer Support
JDBC Webdata


This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Strategic Technology Protection
Program and to order
your FREE Security Tool Kit, please visit
<http://www.microsoft.com/security>.

Aleksandr Stservbakov

unread,
Feb 18, 2002, 8:11:38 AM2/18/02
to
Where can I get this utility ?
Do I have to download/get documentation on it ?

Aleksandr Stservbakov

unread,
Feb 18, 2002, 9:08:21 AM2/18/02
to
I had tried to use spy but with no effect.

Driver is com.microsoft.jdbc.sqlserver.SQLServerDriver
url:
jdbc:spy:{jdbc:microsoft:sqlserver://BLUE:1433;SELECTMETHOD=CURSOR;DATABASENAME=SERVER_3_2_6};
log=(file) h:\dev\od\java\lib\spy.log;linelimit=80

and result is :

java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:477)
at java.sql.DriverManager.getConnection(DriverManager.java:137)


What did I do wrong ?
Thanks.

"Sridhar Paladugu[CompCon tech]" wrote:

Sridhar Paladugu[CompCon tech]

unread,
Feb 18, 2002, 2:12:48 PM2/18/02
to
hi,

I am sending you a sample code for logging using Spy Driver. But as far
support is considered microsoft does not provide support Spy Driver. I am
sending this sample code for review purpose only.


Code:
============================================================================
/*
This code is to test SQLServer Connectivity
*/
import java.sql.*;
import java.io.*;
import com.merant.jdbcspy.*;
public class Test{
private java.sql.Connection con = null;

//constructor
public Test(){}
private Connection getConnection() throws Exception{
con=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Class.forName("com.merant.jdbcspy.SpyDriver");
java.io.OutputStream outFile = new
java.io.FileOutputStream("c:\\logs\\spy.log");
java.io.PrintStream outStream = new java.io.PrintStream (outFile,true);
DriverManager.setLogStream(outStream);
con =
DriverManager.getConnection("jdbc:spy:{jdbc:microsoft:sqlserver://localhost:
1433;DatabaseName=pubs;User=sridhar;Password=password};linelimit=80");
if(con!=null) System.out.println("Con complete");
}catch(SQLException e){
e.printStackTrace();
System.out.println("Error Trace in getConnection() : " +
e.getMessage());
}
return con;
}

public void displayDbProperties(){
DatabaseMetaData dm = null;
ResultSet rs = null;
try{
con= this.getConnection();
if(con!=null){
dm = con.getMetaData();
System.out.println("Driver Name: "+ dm.getDriverName());
System.out.println("Driver Version: "+ dm.getDriverVersion ());
System.out.println("Database Name: "+ dm.getDatabaseProductName());
System.out.println("Database Version: "+
dm.getDatabaseProductVersion());
rs = dm.getSchemas();
while(rs!=null&&rs.next()){
System.out.println("Schema: "+ rs.getString(1));
}
rs.close();
rs = null;
rs = dm.getCatalogs();
while(rs!=null&&rs.next()){
System.out.println("catalog: "+ rs.getString(1));
}
rs.close();
rs = null;
System.out.println("Catalog Seperator :"+ dm.getCatalogSeparator());
String[] tbl_types={"TABLE"};
rs = dm.getTables("pubs","%","%",tbl_types);
while(rs!=null&&rs.next()){
System.out.println("Table: "+ rs.getString(1)+ "." +
rs.getString(2)+"."+ rs.getString(3));
}

}else System.out.println("Error: No active Connection");
}catch(Exception e){
e.printStackTrace();
}
dm=null;
}

private void closeConection(Connection con){
try{
if(con!=null)
con.close();
con=null;
}catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
Test myDbTest = new Test();
myDbTest.displayDbProperties();
}

}

Cheers!

Aleksandr Stservbakov

unread,
Feb 20, 2002, 5:53:15 AM2/20/02
to
Thank you !

"Sridhar Paladugu[CompCon tech]" wrote:

0 new messages