首先要找到一个JDBC的驱动程序,例如使用WebLogic jDriver for Oracle时,直接连接数据库的代码如下:
String driverName = "weblogic.jdbc.oci.Driver";
Driver myDriver = (Driver)Class.forName(driverName).newInstance();
String driverURL = "jdbc:weblogic:oracle";
Properties myProperties = new Properties();
myProperties.put("server", "192.168.0.128");//数据库服务器所在的机器IP
myProperties.put("db", "ZCMRP"); //数据库名
myProperties.put("user", "sa");
myProperties.put("password", "");Connection connection = null;
connection = myDriver.connect(driverURL, myProperties);
String driverName = "weblogic.jdbc.oci.Driver";
Driver myDriver = (Driver)Class.forName(driverName).newInstance();
String driverURL = "jdbc:weblogic:oracle";
Properties myProperties = new Properties();
myProperties.put("server", "192.168.0.128");//数据库服务器所在的机器IP
myProperties.put("db", "ZCMRP"); //数据库名
myProperties.put("user", "sa");
myProperties.put("password", "");Connection connection = null;
connection = myDriver.connect(driverURL, myProperties);
解决方案 »
- IBM WebSphere Integratioin Developer在cvs上无法比对java类代码
- 我用的ssh,并且使用了OpenSessionInView,但是还是could not initialize proxy - no Session
- 时间类型转换问题
- 小弟想问一个JAVA连AS400的问题,求高手
- spring拦截器
- 问一个list处理问题
- *********各位仁兄,struts初学者的初学问题,100分招聘(高手们问题过于简单,不要见笑)*******************
- sun的deploytool工具怎么那么差?在我的电脑上总是不能正确显示窗口
- 请教几个关于ant的问题
- 请问各位大哥,哪有《J2EE全实例教程》这本书的电子版下载,希望出版社的。
- 我该怎样设置?
- 哪里有WebLogic Server 6.1下载?
我在写Java 时可用
Class.forName(“oracle.jdbc.driver.OracleDriver”)
Connection con=DriverManager.getConnection(“jdbc:oracle:thin:@192.168.42.1:1521:Order”,”username”,”password”)进行连接。
我现在想通过调用JavaBean,而JavaBean 调用EJB﹐EJB连接数据库。
请问我该怎样做?请大家多多发言指导!!