的数据源及其权限
<%@ page import = "java.sql.*" %>
<%
String url = "jdbc:odbc:mysql";
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName(driver);
java.sql.Connection conn = DriverManager.getConnection(url,"wushilin","******");
Statement s = conn.createStatement();
s.executeUpdate("insert into test values('asdf')");
ResultSet rs = s.executeQuery("select * from test");
while(rs.next())
{
out.println(rs.getString(1)+"<br>");
}
rs.close();
s.close();
conn.close();
}
catch(Exception e)
{
System.err.println("Error");
}
%>
output:
test
test
test
asdf
asdf
asdf
asdf