1.Cannot load driver class: com.pointbase.xa.xaDataSource2.can't be created with non-existent Pool 连接池要在数据源建好的基础上创建你的opendb() 中是直接用JDBC连接数据库获取数据,而没用到连接池看看这个例子:
1。使用JDBC直接连接SQLServer并获取数据
try { Class.forName("weblogic.jdbc.mssqlserver4.Driver"); Connection con = DriverManager.getConnection("jdbc:weblogic:mssqlserver4:northwind@localhost","sa","");//此处根据你的SQLServer帐户而定。 Statement st = con.createStatement(); ResultSet res = st.executeQuery("select * from employees"); String line = ""; while (res.next()) line = line + res.getString("title")+"\n"; jTextArea1.setText(line); con.close(); } catch (Exception ex) { jTextArea1.setText("error : "+ex.getMessage());}2。使用DataSource连接SQLServer并获取数据 Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); try { Context ctx = new InitialContext(ht); DataSource ds = (DataSource)ctx.lookup("SQLServer"); Connection con = ds.getConnection("system","12345678");//此处是WebLogic7的域用户和密码 Statement st = con.createStatement(); ResultSet res = st.executeQuery("select * from employees"); String line = ""; while (res.next()) line = line + res.getString("notes")+"\n"; jTextArea1.setText(line); con.close(); } catch (Exception ex) { jTextArea1.setText("error : "+ex.getMessage()); }
1。使用JDBC直接连接SQLServer并获取数据
try { Class.forName("weblogic.jdbc.mssqlserver4.Driver"); Connection con = DriverManager.getConnection("jdbc:weblogic:mssqlserver4:northwind@localhost","sa","");//此处根据你的SQLServer帐户而定。 Statement st = con.createStatement(); ResultSet res = st.executeQuery("select * from employees"); String line = ""; while (res.next()) line = line + res.getString("title")+"\n"; jTextArea1.setText(line); con.close(); } catch (Exception ex) { jTextArea1.setText("error : "+ex.getMessage());}2。使用DataSource连接SQLServer并获取数据 Hashtable ht = new Hashtable(); ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); ht.put(Context.PROVIDER_URL,"t3://localhost:7001"); try { Context ctx = new InitialContext(ht); DataSource ds = (DataSource)ctx.lookup("SQLServer"); Connection con = ds.getConnection("system","12345678");//此处是WebLogic7的域用户和密码 Statement st = con.createStatement(); ResultSet res = st.executeQuery("select * from employees"); String line = ""; while (res.next()) line = line + res.getString("notes")+"\n"; jTextArea1.setText(line); con.close(); } catch (Exception ex) { jTextArea1.setText("error : "+ex.getMessage()); }
解决方案 »
- 求实现swing中线程等待用户输入, 用户输入后唤醒线程
- 一个简单的问题:jsp怎么搜索?
- 求助:hibernate 多对多 多对一 多表连接查询问题。
- 一個關於hibernate,struts和jsp的整合問題
- 请高手指教:用Myeclipse新建的hibernate工程中,执行cfg.buildSessionFactory()出错
- 一道笔试题目,难死了
- 为什么CSDN论坛的帖子列举页面(分论坛)用HTML,而帖子内容页面却用XML?
- 初学ejb,在jboss中编写ejb客户端的一个小问题
- 急,在线等待!入门入门,还望大侠们赐教,一个关于Java配置的问题
- 如何部署ejb
- import oracle.sql.* 怎么实现?在线等待谢谢
- Jb8怎么这么烦?
是weblogic里的???
没用就删掉...