Hi,
I am wondering what alternatives there are to writing lines like the following in the source:
DriverManager.registerDriver(new OracleDriver());
Connection connection = DriverManager.getConnection("jdbc:oracle:thin:
@192.168.0.123:1550:db01", "db01", "db01");
try {
...
} catch(SQLException sqlexception) {
...
}
Class files can be downloaded and viewed by users, so lines of code like the ones above shouldn't be hardcoded into the source. Any reading resources or tips would be much appreciated!
I look forward to hearing from you!
Regards,
/Saridski.
Comments
If you are interested in changing those DriverManager.xxxxxx lines you could try this page:
http://java.sun.com/developer/Books/JDBCTutorial/ - Chapter 3; section 3.7 "Using Data Sources".
I came across the DataSource class as means of getting a Connection, but I didn't understand how to connect the name of the given server ("grinder" in the example), which is passed as a String to a cpds.setServerName() method with the database. That's in the first lines of the example.
: Hi,
:
: I am wondering what alternatives there are to writing lines like the following in the source:
:
: DriverManager.registerDriver(new OracleDriver());
: Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.123:1550:db01", "db01", "db01");
: try {
: ...
: } catch(SQLException sqlexception) {
: ...
: }
:
: Class files can be downloaded and viewed by users, so lines of code like the ones above shouldn't be hardcoded into the source. Any reading resources or tips would be much appreciated!
:
: I look forward to hearing from you!
: Regards,
: /Saridski.
:
: