• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IS THERE ANY WAY TO CALL A NON-STATIC METHOD TO STATIC METHOD

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have one method like.


public static connection getConnection()throws SQLException
{
return getConnection(POOL_NAME);
}

It is one file like DBDelegate.java
i have another method in another file ArConnectionPool.java like

public Connection getConnection(String aPoolNameStr) throwsArReportException
{
}



Here How can i call non-static method through static method?

Is there any possible way?

if it is,please tell me.

I am expecting your reply.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

WELCOME TO JAVARANCH!

WAIT, LET ME PRESS THE Caps Lock key... there, that's better.

Note that we have many different forums here. You picked the "Java News" forum, which is for industry-related announcements, not for Java questions. I'll move this thread to the Java in General (Beginner) forum for you, and I'll meet you over there...
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a static method to call a non-static method, the static method needs access to an instance of the class with the non-static method; i.e.,

ArConnectionPool pool = new ArConnectionPool();
pool.getConnection("foo");

Although based on the name of the class, it seems unlikely that you'll want to create an instance of a connection pool each time you access it -- most likely, a single instance will be held in a static variable somewhere.
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic