• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
ozhan kaya
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...
 
Vijitha Kumara
Bartender
Posts: 3914
9
Chrome Fedora Hibernate
  • 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
 
Bauke Scholtz
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic