%StringdriverClass="com.mysql.jdbc.Driver";Stringurl="jdbc:mysql://localhost:3306/news";Stringusername="root";Strin">
主要代码:
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<%
String driverClass="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost:3306/news";
String username="root";
String password="";
Class.forName(driverClass);
Connection conn=DriverManager.getConnection(url,username,password);
Statement stat=conn.createStatement();
ResultSet rs=stat.executeQuery(" * newdb");
%>
<%
while(rs.next()){
}
%>
<%
rs.close();
stat.close();
conn.close();
%>