This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes MysqlDataSource - some basic questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MysqlDataSource - some basic questions" Watch "MysqlDataSource - some basic questions" New topic
Author

MysqlDataSource - some basic questions

Yves Troch
Greenhorn

Joined: Jan 05, 2013
Posts: 4

I'm using a SQL database in an application for the first time, since i'm not used to doing this
I'm a bit confused on what's the right way to do this...
at the moment i'm using a method to create a default "sqlConfig":





then i pass this model on to different methods to get certain information on different tables.
all these methods create a connection, create (or get) a different statement and execute it and then
closes the connection again.
If i go on like this, i guess i'll end up writing a few dozen (or more) methods for all the needed operations...
Is this the right way to go, or am i missing something again ?

edit: removed some not needed code for the example...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MysqlDataSource - some basic questions
 
Similar Threads
spring jdbcTemplate connection
Can you store a MySql DataSource into a Context?
looking for suggestions on better DAO design
JSP mySQL exception
jdbc driver