• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

testing the connection

 
Jay X Brown
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Jay X Brown
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are right and i am embarrassed.
sheepishly,
jb
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic