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()); }
是weblogic里的???
没用就删掉...