Debian下WebLogic数据库连接配置指南
一 环境准备
二 驱动准备与放置
三 在管理控制台创建 JDBC 数据源
四 应用程序 JNDI 引用与测试
<resource-ref>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-description>
<res-ref-name>jdbc/MyDataSource</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-description>
Hashtable<String,String> env = new Hashtable<>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://<admin_ip>:7001");
Context ctx = new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("jdbc/MyDataSource");
Connection conn = ds.getConnection();
// ... use conn ...
conn.close();
五 常见问题与排查