会用 bean 吧?
写一个 .java 然后在 jsp 作为 bean 调用。
然后 .java 里面访问远程 数据库,应该就是和一般的 java 一样了。

解决方案 »

  1.   

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); 
    String url="jdbc:odbc:cert//你的数据库名称";  
    String user="**";  
    String password="**";  
    Connection conn= DriverManager.getConnection(url,user,password);
    Statement stmt=conn.createStatement();
    Jsp远程数据库的连接在程序上和本地没有什么区别,主要是在odbc的设置上需要注意。
      

  2.   

    package SQLCon;
    import java.sql.*;
    public class SQLCon
    {
    private Statement stmt=null; 
    private Connection con=null;   
        public SQLCon() throws Exception
        {
                 
                   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                   con = DriverManager.getConnection("jdbc:microsoft:sqlserver://ip:端口;DatabaseName=数据库","用户名","密码");
                   stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); 
                  
        }
        public ResultSet executeQuery(String cmd) throws Exception 
        {
          ResultSet sqlRst = stmt.executeQuery(cmd);
          return sqlRst;
        }
        public void executeUpdate(String cmd) throws Exception
        {
         stmt.executeUpdate(cmd);
        }
        
        public void close() throws SQLException
        {
         if(stmt!=null)stmt.close();
            if(con!=null)con.close();
        }    
    }
      

  3.   

    <%@ page contentType="text/html;charset=gb2312"%>  
    <%@ page import="java.sql.*"%>  
    <html>  
    <body>  
    <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();  
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";  
    //pubs为你的数据库的  ,把localhost改成机器名或者Ip就行了
    String user="sa";  
    String password="";  
    Connection conn= DriverManager.getConnection(url,user,password);  
      

  4.   

    好象提示是No suitable driver
    我是不是要加什么驱动呢,哪里有这个包下载啊?
      

  5.   

    请问哪里SQL Server 7.0 的JDBC driver啊?