Solved

JDBC CONNECTION

Posted on 2010-11-30
5
259 Views
Last Modified: 2012-05-10
Is it possible to establish a database connectivity through JDBC once in the beginning of application and than executing SQL queries through out the application even in called classes

Regards

Milind
0
Comment
Question by:MILIND_JOG
5 Comments
 
LVL 5

Expert Comment

by:agsapt
ID: 34240797
Of course you can. Use persistent connection to your database and you will be all right.


-=@gS=-
0
 

Author Comment

by:MILIND_JOG
ID: 34241733
Thanks for responce. It's 01:00 AM. I will come nack tomorrow.

Thanks

Milind
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34241889
ya you can ....

but if your close the window of the ur application then connection still remine , next it will creat a new connection only . so it will become huge problem  
0
 
LVL 4

Expert Comment

by:Lo-Tan
ID: 34243350
Why do you want to execute random SQL statements throughout your application?  Look at something like JPA for Java.  Create a simple layer for talking to your database model and put all the jpa behind that.  Then use that service wherever you need to run 'sql statements'.

Or open a JDBC connection and stuff it into a system property / Singleton class...   I don't really know what you're doing, but what you want to do doesn't sound practical/maintainable.
0
 
LVL 5

Accepted Solution

by:
agsapt earned 500 total points
ID: 34245503
The question would be how you structure your application to let this to happen? There are some techniques you can implement to allow such feature to exist in your application source code. And as stated by Lo-Tan, JPA for java is one of them.

But you can also write your own simple class that would implement an interface that contains commonly used functions related to database. E.g.

- createConnection
- createStatement,
- createParameters,
- executeQuery
- executeNonQuery
- etc .. etc ..

And make sure your class can be accessible from anywhere within your codes.

-=@gS=-
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This video teaches viewers about errors in exception handling.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now