asp中下面有这些信息,大伙儿帮我看一下能不能访问到ORACLE!(JSP也可以)(100分)

  • 主题发起人 主题发起人 thinkjsp
  • 开始时间 开始时间
T

thinkjsp

Unregistered / Unconfirmed
GUEST, unregistred user!
我这边有主机IP地址,端口,一个视图,一个用户
要求通过这个视图查询一个信息!!
这样应该怎么连接这个数据库啊??
分数不够可以再加!!
 
你不知道用户名密码,怎么能连上数据库??
 
用户名密码知道的话,连接字符串应该怎么写呢??
 
java(jsp)中
package DBstep;
import java.sql.*;
import java.lang.*;
import java.text.*;
import java.util.*;
public class iDBManager2000 {
public String ClassString=null;
public String ConnectionString=null;
public String UserName=null;
public String PassWord=null;

public Connection Conn;
public Statement Stmt;
public PreparedStatement prestmt=null;
public int concurType=ResultSet.CONCUR_READ_ONLY;
public int scrollType=ResultSet.TYPE_SCROLL_INSENSITIVE;

//构造函数(初始化)
public iDBManager2000() {


//For Oracle Driver
//ClassString="oracle.jdbc.driver.OracleDriver";
//ConnectionString="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为你的数据库的SID
//UserName=...;
//PassWord=...;


//For BBS Conn
public java.sql.Connection getBBSConn(){
try{
Class.forName(ClassString).newInstance();
if ((UserName==null) &&
(PassWord==null))
{
Conn= DriverManager.getConnection(ConnectionString);
}else
{
Conn= DriverManager.getConnection(ConnectionString,UserName,PassWord);
}
}catch(Exception e){
e.printStackTrace();
System.out.println("LICHAO");
}
return Conn ;
}
//打开数据库
public boolean OpenConnection()
{
boolean mResult=true;
try
{
Class.forName(ClassString).newInstance();
if ((UserName==null) &&
(PassWord==null))
{
Conn= DriverManager.getConnection(ConnectionString);
}
else
{
Conn= DriverManager.getConnection(ConnectionString,UserName,PassWord);
}
Stmt=Conn.createStatement(scrollType,concurType);
mResult=true;
}
catch(Exception e)
{
System.out.println(e.toString());
mResult=false;
}
return (mResult);
}

//关闭数据库连接
public void CloseConnection()
{
try
{
Stmt.close();
Conn.close();
}
catch(Exception e)
{
System.out.println(e.toString());
}
}

//执行查询语句
public ResultSet ExecuteQuery(String SqlString)
{
ResultSet result=null;
try
{
result=Stmt.executeQuery(SqlString);
}
catch(Exception e)
{
System.out.println(e.toString());
}
return (result);
}
//执行修改语句
public int ExecuteUpdate(String SqlString)
{
int result=0;
try
{
result=Stmt.executeUpdate(SqlString);
}
catch(Exception e)
{
System.out.println(e.toString());
}
return (result);
}
//获得当前页面的第一条记录
public int getPageResult(int pageSize,int pageNumber)
{
int result=0;
try
{
result=pageSize*(pageNumber-1);
}
catch(Exception e)
{
System.out.println(e.toString());
}
if(result==0)
{ result=1;
}
return (result);
}

//获得总页数
public int getPageCount(int pageSize,int pageCount)
{
int result=0;
try
{
if(pageCount%pageSize==0)
{
result=pageCount/pageSize;
}
else
{
result=(int)(pageCount/pageSize+1);
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
return (result);
}
//获得总记录数
public int getRecordCount(String SqlString)
{
ResultSet result=null;
int recordCount=0;
try
{
result=Stmt.executeQuery(SqlString);
if(result==null)
{
return (0);
}
else

{
result.next();
recordCount=result.getInt("count");
}

}
catch(Exception e)
{
System.out.println(e.toString());
}
return (recordCount);
}
//封装的修改方法
public int executeUpd (String SqlString)
{
int result=0;
try
{
prestmt=Conn.prepareStatement(SqlString);
Conn.setAutoCommit(true);
result=Stmt.executeUpdate(SqlString);
Conn.commit();
}
catch(Exception e)
{
System.out.println(e.toString());
}
return (result);
}

}
 
后退
顶部