为数据库设置权限(用户和密码) 命令:grant all privileges on first.* to test@localhost identified by “123456”; 当你执行完这个命令以后,只要你再以用户名:test,密码:123456登录时你就只可以对first这个数据库操作,这样避开使用root 输入命令:use first; 使用first数据库;
import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class HelloWorld extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException {
response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.println("This is my first Servlet"); out.println(""); out.println("
用记事本新建一个java程序,文件名为TestBean.java,文件内容如下: package test; public class TestBean{ private String name = null; public TestBean(String strName_p){ this.name=strName_p; } public void setName(String strName_p){ this.name=strName_p; } public String getName(){ return this.name; } }