去google搜索一下,另外csdn的文档里有很多关于这个方面的

解决方案 »

  1.   

    楼上的诸位简直是为up贴而up贴,无话可说!!
    首先把三个*.jar文件放到了tomcat\common\lib的目录下.<%@ page contentType="text/html;charset=gb2312"%> 
    <%@ page import="java.sql.*"%> 
      
    <html> 
    <body> 
    <div align="left">
    <%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
    String url="jdbc:microsoft:sqlserver://super-happy:1433;DatabaseName=test"; 
    String user="sa";
    String password="";
    Connection conn= DriverManager.getConnection(url,user,password); 
     Statement statement = conn.createStatement();
    String sql="select * from  test";
    ResultSet rs=statement.executeQuery(sql); 
    while(rs.next()) {%> 
    no1:<%=rs.getString(1)%><br>
    no2:<%=rs.getString(2)%><br> 
    no3:<%=rs.getString(3)%><br>
    no4:<%=rs.getString(4)%><br>
    no5:<%=rs.getString(5)%><p>
    <p>
        <%}%> 
        <%out.print("数据库操作成功,开心死了");%> 
        <%rs.close(); %>
        <%statement.close(); %>
        <%conn.close(); %>
         
      </p>
    <p>&nbsp;</p>
    </div>
    </body> 
      </html>
      

  2.   

    给大家一个小东西吧,以前自己做的,http://www.flash8.net/bbs/dispbbs.asp?BoardID=17&ID=158941,下载的用户名是:Y1937,密码是:828,谢谢大家
      

  3.   

    这是一个ORACLE的,改一下配置文件就可以了.package siwei.tools;
    import java.sql.*;
    import java.io.*;
    import java.util.Properties;public class SqlBean{    private String connDriver =null;
        private String dbUrl =null;//数据库的地址和端口号
        private Connection myConn = null;
        private Statement stmt = null;
        private ResultSet rs = null;
        private String user = null;
        private String pass = null;    public SqlBean(){
              }
        public SqlBean(String Driver,String DbUrl,String User,String Pass){
            connDriver = Driver;
            dbUrl = DbUrl;
            user = User;
            pass = Pass;
        }
        public void makeConn() throws Exception{//完成连接数据库的功能
            if(connDriver==null)
            connDriver = getProperties("Driver");
            if(dbUrl==null)
            dbUrl = getProperties("dbUrl");
            if(user==null)
            user = getProperties("user");
            if(pass==null)
            pass = getProperties("pass");
            Class.forName(connDriver);//找oracle的驱动
    myConn=DriverManager.getConnection(dbUrl,user,pass); //连接数据库
        }
       public boolean sqlQuery(String sql) throws Exception{//执行select语句
           stmt=myConn.createStatement();
           rs=stmt.executeQuery(sql);
           return (rs!=null);
       }
       public boolean getNext() throws Exception{//看数据库的下一个数据是否为空
           return (rs.next());
       }
       public String getString(String inCol) throws Exception{//取得对应数据库字段的数据
           return rs.getString(inCol);
       }
       public int getInt(String inCol) throws Exception{//取得对应数据库整型字段的数据
           return rs.getInt(inCol);
       }
       public double getDouble(String inCol) throws Exception{//取得对应数据库整型字段的数据double
           return  rs.getDouble(inCol);
       }
       public void sqlUpdate(String sql) throws Exception{//执行update、delete、insert的sql语句
           stmt=null;
           stmt=myConn.createStatement();
           stmt.executeUpdate(sql);
       }   public void closeAll() throws Exception{
    if(rs!=null)
             rs.close();
            if(stmt != null)
    stmt.close();
            if(myConn != null)
                    myConn.close();
       }
       public void closeConn() throws Exception{//关闭所有的与数据库相关的操作
           if(stmt != null)
                   stmt.close();
          if(myConn != null)
                    myConn.close();
       }
       public void closeRs() throws Exception{
             if(rs != null)
                   rs.close();
       }
       public void closeStmt() throws Exception{
    if(stmt != null)
                  stmt.close();
       }
       public void closeConnect() throws Exception{
            if(myConn != null)
        myConn.close();
       }
       public String getProperties(String Pname) throws Exception{
    String dbUser = null;
    String fileName = "/config/POIdb.properties";//POIdb.properties不数据库配置文件
                    InputStream inputstream=getClass().getResourceAsStream(fileName);
                    /*fd.read();
    BufferedReader br = new BufferedReader(fd);
    dbUser = br.readLine();
    fd.close();
    br.close();*/
                    Properties properties = new Properties();
                    properties.load(inputstream);
                    dbUser = properties.getProperty(Pname);
                   return dbUser;
       }
    }在JSP页面中,只要定义一个实例或定义一个JAVABEAN就可以了.