日期:2014-05-16  浏览次数:20753 次

关于将前台信息录入数据库的问题 请高手指导 谢谢
各位 高人 诚恳请教
我先在html里简单这两个文本框输入 名字和年龄
 name<input type="text" name="xingmin">
 age<input type="text" name="nianlin">

然后编个一个servlet相应
response.setContentType("text/html;charset=gb2312");
PrintWriter out=response.getWriter();
out.println("输入的姓名:"+request.getParameter("xingming"));
out.println("<br>");
out.println("<br>");
out.println("输入的年龄:"+request.getParameter("nianlin"));

第三步想吧 第一步两个文本框里的名字和年龄 按提交后 存储在mysql数据库中。
 我只知道怎么从数据库select 查不到怎么录入 怎么编写jdbc? 该怎么做 第一次跑这样的程序 怎么做 请教高人 信息录入 万分感谢 谢谢

------解决方案--------------------
引用21.4.4. Connector/J (JDBC) Reference
This section of the manual contains reference material for MySQL Connector/J, some of which is automatically generated during the Connector/J build process.

21.4.4.1. Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J
The name of the class that implements java.sql.Driver in MySQL Connector/J is com.mysql.jdbc.Driver. The org.gjt.mm.mysql.Driver class name is also usable to remain backward-compatible with MM.MySQL. You should use this class name when registering the driver, or when otherwise configuring software to use MySQL Connector/J.

The JDBC URL format for MySQL Connector/J is as follows, with items in square brackets ([, ]) being optional:

jdbc:mysql://[host][,failoverhost...][:port]/[database] ?
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
If the host name is not specified, it defaults to 127.0.0.1. If the port is not specified, it defaults to 3306, the default port number for MySQL servers.

jdbc:mysql://[host:port],[host:port].../[database] ?
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...