Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / January 2005

Tip: Looking for answers? Try searching our database.

Debug a JDBC application in Eclipse

Thread view: 
Randy - 11 Jan 2005 18:53 GMT
I would like to be able to step through an application that is
connected to a database (using JDBC) in Eclipse.  Can this be done?
Does anyone have a code snippet that would allow me to do this?
Thanx,

Randy
leue@crd.ge.com - 11 Jan 2005 19:12 GMT
I work on JDBC applications in Eclipse, and the debugger works fine.
However, I assume you want to step into the JDBC API code itself,
right? Other than not being able to see what is happening on the other
side of the network connection to the actual D/B server, I don't see
why you shouldn't be able to just step right into the JDBC API code,
just like you would step into any other API code. Be prepared for
verbosity, of course :)

-Bill Leue
Randy - 11 Jan 2005 20:28 GMT
I don't need to see what is happening inside the JDBC API.  I am new to
the Java world (coming from a VB background), and I would like to debug
my application inside Eclipse without creating the jar, deploying it,
then starting JBoss.

I have tried to create a test application that executes a small query,
but when I try to get a connection to the database, I get the following
error:

Error finding DataSource: javax.naming.NoInitialContextException: Need
to specify class name in environment or system property, or as an
applet parameter, or in an application resource file:
java.naming.factory.initial
java.lang.NullPointerException
Trapper - 12 Jan 2005 02:11 GMT
> I don't need to see what is happening inside the JDBC API.  I am new to
> the Java world (coming from a VB background), and I would like to debug
[quoted text clipped - 10 lines]
> java.naming.factory.initial
> java.lang.NullPointerException

Have you tried specifying the required args for this program in the
Arguments section?
Randy - 12 Jan 2005 21:33 GMT
I have the following code in my test class:

public static void main(String[] args)
{
DataSource ds = null;
//String line;

String pSQL = "SELECT ";
pSQL = pSQL + "    * ";
pSQL = pSQL + "FROM ";
pSQL = pSQL + "    Product ";

String pDatasource = "java:TeradataDS";

try
{
// Load the Teradata Driver
Class.forName("com.ncr.teradata.TeraDriver");
}
catch (ClassNotFoundException e)
{
System.out.println(e);
}

try
{
Context c = new InitialContext();
ds = (DataSource) c.lookup (pDatasource);
//"java:TeradataDS"
}
catch (Exception e1)
{
System.out.println("Error finding DataSource: " + e1);
}
try
{
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(pSQL);
}
catch (Exception e2)
{
System.out.println(e2);
}
}

It is failing on the lookup of the DataSource with the following
message:

Error finding DataSource: javax.naming.NoInitialContextException: Need
to specify class name in environment or system property, or as an
applet parameter, or in an application resource file:
java.naming.factory.initial
java.lang.NullPointerException

Am I missing some kind of supporting file?  I have an XML file with my
datasource in my JBoss directory.

Randy
Trapper - 13 Jan 2005 00:09 GMT
> I have the following code in my test class:
>
[quoted text clipped - 55 lines]
>
> Randy

http://java.sun.com/products/jndi/tutorial/getStarted/faq/runtime.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.