aspose file tools*
The moose likes JDBC and the fly likes testing the connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "testing the connection" Watch "testing the connection" New topic
Author

testing the connection

Jay X Brown
Ranch Hand

Joined: Jan 26, 2001
Posts: 51
greetings to the gurus,
i am having an error problem when i try to test my jdbc connection.
at first i got a calling a nonstatic method error when, in the main method, i did the following:
try
{
dbaseConn = makeConnection();
}
catch (Exception ex)
{
log("Sybase Connect Error: "+ex.getMessage());
}
(where makeConnection is the method where i link with my database and give the sql commands)
then, i changed this to create an instance of the nonstatic method in main by:
try
{
makeConnection testConn=new makeConnection();
// dbaseConn = makeConnection();
}
catch (Exception ex)
{
log("Sybase Connect Error: "+ex.getMessage());
}

now the error it gives is:
>Class makeConnection not found in type declaration.
> makeConnection testConn=new makeConnection();
what am i doing wrong?
jb
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
It seems like you are confused about the difference between a method and a class. We only use new() on classes, not methods. So let's say that makeConnection is a method in class MyConnection, then we would do this:
MyConnection mc = new MyConnection();
dbaseConn = mc.makeConnection();

[This message has been edited by Thomas Paul (edited February 12, 2001).]


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Jay X Brown
Ranch Hand

Joined: Jan 26, 2001
Posts: 51
you are right and i am embarrassed.
sheepishly,
jb
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: testing the connection