本来我是用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 真是不知道怎么回事啊:(
如果是oracle:
String url="jdbc:oracle:thin:@localhost:1521:数据库名";
如果是sqlserver:
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";//mydb是数据库名
re:
CoolAbu
DNS数据源设置好了
并且在java application下运行没有问题
产生inuse文件,里面内容是jdbc 2。0
<%@ page import="java.sql.*"%>你把这两句放到页的最顶端。
刚才装了一个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
真是不知道怎么回事啊:(
果然是这个问题啊
:)
谢谢大家帮忙
如:java.sql.*;