连接数据库的代码:
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/jsp?useUnicode=true&characterEncoding=GB2312";
String user="root";
String pass="ccqqsea";
con=DriverManager.getConnection(url,user,pass);
stmt=con.createStatement();
String sql="select * from user";
rs=stmt.executeQuery (sql);
int s1=rs.getInt(1);
String s2=rs.getString("USER_NAME");
out.print(s1+s2);
}catch(Exception e){out.print(e.getMessage());}
%>
运行显示为:
com.mysql.jdbc.Driver
不知道到底连上了伐
还有我的server.xml是
<Server port="8005" shutdown="SHUTDOWN" debug="0">
<Service name="Tomcat-Standalone">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
port="8081" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
<Engine>
<Host name="localhost" debug="0" appBase="g:\"
unpackWARs="true" autoDeploy="true">
<Context path="" docBase="jsp">
</Context>
</Host>
</Engine>
</Service>
</Server>