Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How i can reach Resultset Connection variables outside Class or from inner method

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know I telled true or not(i know resultset not a variable).But after see my code you can understand.I have a connect database class.I have a method for connection and execute queries.



I plan use a lot of different methods using this connection.But i don't want to use Classforname,Connection codes in every single method.I tryed to make a constructor but did not worked.I mean how i can make this possible and how i can reach Cnctdb , sqldb ... from another class(i succesed in swing objects but failed in connection).

Thanks in advance...
 
Bartender
Posts: 4107
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should move that, "getting a connection" code in to factory class which will initialize when the application starts and can be used to get connections.

Here is just a brief guide to get started. You may add many features/functions to enhance or make it more usable later.



And You know how to use this class in client code right ?
 
ozhan kaya
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Vijitha Kumara.I even tryed this > static Resultset
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ozhan kaya wrote:I tryed to make a constructor but did not worked.


It will work if you code it the right way and removed the 'static' modifier.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ozhan kaya wrote:Thanks a lot Vijitha Kumara.I even tryed this > static Resultset


Very bad idea. Go back to your basic Java book/tutorial and carefully learn what the 'static' modifier does.
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic