weblogic下獲取資料庫連線

2021-05-24 07:22:28 字數 676 閱讀 5164

趁還沒有忘,趕緊寫下來吧。。

//1,初始化伺服器上下文

//1.1設定url

string url = "t3://localhost:7001";//t3是eba公司特定的表示,同http協議,只是名字不同,用來區別一下的。7001是埠,

//同tomcat的8080

//1.2設定dirver

string driver = "weblogic.jndi.wlinitialcontextfactory";

//1.3把連線weblogic伺服器的資訊存入properties容器

properties p = new properties();

p.put(context.provider_url,url);

p.put(context.initial_context_foctory,driver);

//1.4把properties物件作為引數

context context = new context(p);

//2、獲取資料源

datasource ds = (datasource)context.lookup("jndi名字");

//3、返回連線

return ds.getconnection();

2023年9月6日 17:27:21

by:frank

Python 下 pymysql 資料庫重新連線

這是pymysql的問題吧?為什麼超時時間設定不起作用,為什麼不自動重連一下呢?好在提供了乙個 ping 方法 ping self,reconnect true check if the server is alive.param reconnect if the connection is clo...

資料庫重連

4.2.10 資料庫自動重連 dbcp使用apache的物件池objectpool作為連線池的實現,在構造genericobjectpool時,會生成乙個內嵌類evictor,實現自runnable介面。如果 timebetweenevictionrunsmillis大於0,每過 timebetwe...

JDBC連Oracle資料庫

string drivername oracle.jdbc.driver.oracledriver string url jdbc oracle thin 172.28.139.78 1521 oracts string username scott string password tiger tr...