hgbdelphi
asked on
can experts tell me different about container datasource and jdbc connection?
hi,experts,
i don't know about define connection in jboss datasource and define connection in my class will some different,can tell me?
in jboss,i define connection in *.xml,like this
<datasources>
<local-tx-datasource>
<jndi-name>MSSQLDS</jndi-n ame>
<connection-url>jdbc:micro soft:sqlse rver://loc alhost:143 3;Database Name=Commu nityMedica l</connect ion-url>
<driver-class>com.microsof t.jdbc.sql server.SQL ServerDriv er</driver -class>
<user-name>sa</user-name>
<password>btn</password>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sq l>some arbitrary sql</check-valid-connectio n-sql>
-->
</local-tx-datasource>
</datasources>
and i will call like this in jsp:
Context ctx = new InitialContext();
ds = (javax.sql.DataSource)ctx. lookup("ja va:/MSSQLD S");
Connection conn=ds.getConnection();
Statement dbConn=conn.createStatemen t();
and i define my connection in myclass,like this
public DBConn() {
String sqlDriver = ConfigFile.SQL_Driver;
String sqlJdbc = ConfigFile.SQL_JDBC;
String sqlUser = ConfigFile.SQL_USER;
String sqlPwd = ConfigFile.SQL_PWD;
try {
Class.forName(sqlDriver);
conn = DriverManager.getConnectio n(sqlJdbc, sqlUser, sqlPwd);
stmtScroll = conn.createStatement(Resul tSet.TYPE_ SCROLL_INS ENSITIVE,R esultSet.C ONCUR_UPDA TABLE);
stmt = conn.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}
i don't know two type get connection will some different, efficiency?standard?or ....
thanks!
i don't know about define connection in jboss datasource and define connection in my class will some different,can tell me?
in jboss,i define connection in *.xml,like this
<datasources>
<local-tx-datasource>
<jndi-name>MSSQLDS</jndi-n
<connection-url>jdbc:micro
<driver-class>com.microsof
<user-name>sa</user-name>
<password>btn</password>
<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sq
-->
</local-tx-datasource>
</datasources>
and i will call like this in jsp:
Context ctx = new InitialContext();
ds = (javax.sql.DataSource)ctx.
Connection conn=ds.getConnection();
Statement dbConn=conn.createStatemen
and i define my connection in myclass,like this
public DBConn() {
String sqlDriver = ConfigFile.SQL_Driver;
String sqlJdbc = ConfigFile.SQL_JDBC;
String sqlUser = ConfigFile.SQL_USER;
String sqlPwd = ConfigFile.SQL_PWD;
try {
Class.forName(sqlDriver);
conn = DriverManager.getConnectio
stmtScroll = conn.createStatement(Resul
stmt = conn.createStatement();
} catch (Exception e) {
e.printStackTrace();
}
}
i don't know two type get connection will some different, efficiency?standard?or ....
thanks!
ASKER
and anything....,rapaid?effici ency?
thanks!
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks,i will create connection pool.
Regard!
Regard!
If you want to change something like username/password to access database, no need to recompile source code and have a central of management resource.