String url="jdbc:odbc:testdb"; 
数据库的url写法有点问题,
应该这样:String database = "jdbc:oracle:thin:@192.168.91.66:1521:macaudb";
你可以试一试!

解决方案 »

  1.   

    String url="jdbc:odbc:testdb"; //你有testdb这个DNS数据源么?ODBC中设置了?
      

  2.   

    你用的数据库是什么?String url="jdbc:odbc:testdb"; 这个好像没见过啊
    如果是oracle:
    String url="jdbc:oracle:thin:@localhost:1521:数据库名";
    如果是sqlserver:
    String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";//mydb是数据库名
      

  3.   

    用的jdbc-odbc桥,我的及其单独使用jadc驱动始终会报错“no suitable driver”
    re: 
    CoolAbu
    DNS数据源设置好了
    并且在java application下运行没有问题
      

  4.   

    你的sqlser的驱动装了吗?看看检查一下
      

  5.   

    可以设断点执行,先看库连上了吗?连上输入信息“OK”,在执行SQL输出结果,把url在认真重新写一遍.
      

  6.   

    db2驱动:是在java12目录下运行usejdbc2.bat
    产生inuse文件,里面内容是jdbc 2。0
      

  7.   

    加入import java.sql.*;即可!!!
      

  8.   

    <%@ page language="java" contentType="text/html; charset=GB2312" %>
    <%@ page import="java.sql.*"%>你把这两句放到页的最顶端。
      

  9.   

    本来我是用websphere的
    刚才装了一个Jbuilder运行,代码如下
    <%@ page language="java" contentType="text/html; charset=GB2312" %>
    <%@ page import="java.sql.*"%><HTML>
    <BODY>
    <P><%
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
      String url="jdbc:odbc:testdb"; 
      //数据库名 
      String user="fox";
      String password="79";
      Connection conn= DriverManager.getConnection(url,user,password); 
      Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
      String sql="select * from testtable"; 
      ResultSet rs=stmt.executeQuery(sql); 
      while(rs.next()) {%> 
      第一个字段内容为:<%=rs.getString(1)%> 
      第二个字段内容为:<%=rs.getString(2)%> 
      <%}%> 
      <%out.print("数据库操作成功,恭喜你");%> 
      <%rs.close(); 
      stmt.close(); 
      conn.close(); 
      %> </P>
    </BODY>
    </HTML>
    还是有错:
    "jsp1.jsp": Error #: 100 : illegal character at line 10
    "jsp1.jsp": Error #: 100 : illegal character at line 10
    "jsp1.jsp": Error #: 206 : malformed expression at line 9
    "jsp1.jsp": Error #: 100 : illegal character at line 11
    "jsp1.jsp": Error #: 100 : illegal character at line 11
    "jsp1.jsp": Error #: 100 : illegal character at line 12
    "jsp1.jsp": Error #: 100 : illegal character at line 12
    "jsp1.jsp": Error #: 206 : malformed expression at line 10
    "jsp1.jsp": Error #: 100 : illegal character at line 13
    "jsp1.jsp": Error #: 100 : illegal character at line 13
    "jsp1.jsp": Error #: 206 : malformed expression at line 11
    "jsp1.jsp": Error #: 100 : illegal character at line 14
    "jsp1.jsp": Error #: 100 : illegal character at line 14
    "jsp1.jsp": Error #: 206 : malformed expression at line 13
    "jsp1.jsp": Error #: 100 : illegal character at line 15
    "jsp1.jsp": Error #: 100 : illegal character at line 15
    "jsp1.jsp": Error #: 206 : malformed expression at line 14
    "jsp1.jsp": Error #: 100 : illegal character at line 16
    "jsp1.jsp": Error #: 100 : illegal character at line 16
    "jsp1.jsp": Error #: 206 : malformed expression at line 15
    "jsp1.jsp": Error #: 100 : illegal character at line 17
    "jsp1.jsp": Error #: 100 : illegal character at line 17
    "jsp1.jsp": Error #: 206 : malformed expression at line 16
    "jsp1.jsp": Error #: 100 : illegal character at line 18
    "jsp1.jsp": Error #: 100 : illegal character at line 18
    "jsp1.jsp": Error #: 206 : malformed expression at line 17
    "jsp1.jsp": Error #: 100 : illegal character at line 24
    "jsp1.jsp": Error #: 100 : illegal character at line 24
    "jsp1.jsp": Error #: 206 : malformed expression at line 23
    "jsp1.jsp": Error #: 100 : illegal character at line 25
    "jsp1.jsp": Error #: 100 : illegal character at line 25
    "jsp1.jsp": Error #: 206 : malformed expression at line 24
    "jsp1.jsp": Error #: 100 : illegal character at line 26
    "jsp1.jsp": Error #: 100 : illegal character at line 26
    "jsp1.jsp": Error #: 206 : malformed expression at line 25
    真是不知道怎么回事啊:(
      

  10.   

    谢谢 bravowell
    果然是这个问题啊
    :)
    谢谢大家帮忙
      

  11.   

    添加一些必要的包
    如:java.sql.*;