2011-05-05
展开全部
--先连接数据库,再打开记录集,搞定。
Dim conn_ora As New ADODB.Connection '用于连接ORACLE数据源的连接
conn_ora.ConnectionString = "Provider=MSDAORA.1;Password=111;User ID=system ;Data Source=orcl;Persist Security Info=True"
conn_ora.Open
Dim myrs_ora As New ADODB.Recordset '用于连接ORACLE数据库的记录集
myrs_ora.ActiveConnection = conn_ora.ConnectionString
myrs_ora.Open ("Select * From AAA")
另外,站长团上有产品团购,便宜有保证
Dim conn_ora As New ADODB.Connection '用于连接ORACLE数据源的连接
conn_ora.ConnectionString = "Provider=MSDAORA.1;Password=111;User ID=system ;Data Source=orcl;Persist Security Info=True"
conn_ora.Open
Dim myrs_ora As New ADODB.Recordset '用于连接ORACLE数据库的记录集
myrs_ora.ActiveConnection = conn_ora.ConnectionString
myrs_ora.Open ("Select * From AAA")
另外,站长团上有产品团购,便宜有保证
展开全部
这是我程序的一段代码,你看看吧,希望对你有帮助~~
package com.yuandong.bbsjdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
public class Jdbc {
// private String driver = "oracle.jdbc.driver.OracleDriver";
// private String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
private String driver = null;
private String url = null;
private String username = null;
private String password = null;
private Connection con = null;
private PreparedStatement pst = null;
private ResultSet rs = null;
private int i = 0;
public Jdbc(){
ResourceBundle rob = ResourceBundle.getBundle("jdbc");
driver = rob.getString("driver");
url = rob.getString("url");
username = rob.getString("uname");
password = rob.getString("upass");
//System.out.println(driver + " " + url + " " + username + " " + password);
getConnection();
}
public Connection getConnection(){
try {
try {
Class.forName(driver).newInstance();
try {
con = DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
public PreparedStatement getPreparedStatement(String sql){
try {
pst = con.prepareStatement(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return pst;
}
public ResultSet getExecuteQuery(){
//查询
try {
rs = pst.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rs;
}
public int getExecuteUpdate(){
//修改
try {
i = pst.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return i;
}
}
package com.yuandong.bbsjdbc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ResourceBundle;
public class Jdbc {
// private String driver = "oracle.jdbc.driver.OracleDriver";
// private String url = "jdbc:oracle:thin:@127.0.0.1:1521:orcl";
private String driver = null;
private String url = null;
private String username = null;
private String password = null;
private Connection con = null;
private PreparedStatement pst = null;
private ResultSet rs = null;
private int i = 0;
public Jdbc(){
ResourceBundle rob = ResourceBundle.getBundle("jdbc");
driver = rob.getString("driver");
url = rob.getString("url");
username = rob.getString("uname");
password = rob.getString("upass");
//System.out.println(driver + " " + url + " " + username + " " + password);
getConnection();
}
public Connection getConnection(){
try {
try {
Class.forName(driver).newInstance();
try {
con = DriverManager.getConnection(url,username,password);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return con;
}
public PreparedStatement getPreparedStatement(String sql){
try {
pst = con.prepareStatement(sql);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return pst;
}
public ResultSet getExecuteQuery(){
//查询
try {
rs = pst.executeQuery();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return rs;
}
public int getExecuteUpdate(){
//修改
try {
i = pst.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return i;
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询