用MyEclipse工具并用SQLServer方法插入数据库 用MyEclipse工具并用SQLServer方法插入数据库我怎么插都插不进去为什么呢?才开始我以为是我的数据库设计的有问题,我又重新设计了一个,又检查了一边代码,都没有问题了,可是就是插不进去为什么啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 此回复为自动发出,仅用于显示而已,并无任何其他特殊作用楼主【lwl_wm】截止到2008-07-09 16:45:16的历史汇总数据(不包括此帖):发帖的总数量:4 发帖的总分数:40 每贴平均分数:10 回帖的总数量:3 得分贴总数量:0 回帖的得分率:0% 结贴的总数量:2 结贴的总分数:0 无满意结贴数:2 无满意结贴分:40 未结的帖子数:2 未结的总分数:40 结贴的百分比:50.00 % 结分的百分比:0.00 % 无满意结贴率:100.00% 无满意结分率:---------------------楼主加油 /* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */package com.wm.struts.form;import java.sql.*;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;/** * MyEclipse Struts * Creation date: 07-08-2008 * * XDoclet definition: * @struts.form name="adminInfoForm" */public class AdminInfoForm extends ActionForm { /* * Generated fields */ /** class1 property */ private String class1; /** title property */ private String title; /** telephone property */ private String telephone; /** content property */ private String content; /** name property */ private String name; /* * Generated Methods */ /** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // TODO Auto-generated method stub return null; } /** * Method reset * @param mapping * @param request */ public void reset(ActionMapping mapping, HttpServletRequest request) { // TODO Auto-generated method stub } /** * Returns the class1. * @return String */ public String getClass1() { return class1; } /** * Set the class1. * @param class1 The class1 to set */ public void setClass1(String class1) { this.class1 = class1; } /** * Returns the title. * @return String */ public String getTitle() { return title; } /** * Set the title. * @param title The title to set */ public void setTitle(String title) { this.title = title; } /** * Returns the telephone. * @return String */ public String getTelephone() { return telephone; } /** * Set the telephone. * @param telephone The telephone to set */ public void setTelephone(String telephone) { this.telephone = telephone; } /** * Returns the content. * @return String */ public String getContent() { return content; } /** * Set the content. * @param content The content to set */ public void setContent(String content) { this.content = content; } /** * Returns the name. * @return String */ public String getName() { return name; } /** * Set the name. * @param name The name to set */ public void setName(String name) { this.name = name; } public void insert() throws Exception{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn =DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=NewDB","sa","sa"); String sql="insert into info(name,title,content,telephone,class) values('"+this.name+"','"+this.title+",'"+this.content+"','"+this.telephone+"','"+this.class1+"')"; Statement stmt =conn.createStatement(); stmt.executeUpdate(sql); } } 这是actionForm中的代码数据库中有以下几个字段:id(自动编号),name,title,content,time,modifyTime,telephone,class(是个主键约束,以它传值连接另一个表) /* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */ package com.wm.struts.form; import java.sql.*; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; /** * MyEclipse Struts * Creation date: 07-08-2008 * * XDoclet definition: * @struts.form name="adminInfoForm" */ public class AdminInfoForm extends ActionForm { /* * Generated fields */ /** class1 property */ private String class1; /** title property */ private String title; /** telephone property */ private String telephone; /** content property */ private String content; /** name property */ private String name; /* * Generated Methods */ /** * Method validate * @param mapping * @param request * @return ActionErrors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { // TODO Auto-generated method stub return null; } /** * Method reset * @param mapping * @param request */ public void reset(ActionMapping mapping, HttpServletRequest request) { // TODO Auto-generated method stub } /** * Returns the class1. * @return String */ public String getClass1() { return class1; } /** * Set the class1. * @param class1 The class1 to set */ public void setClass1(String class1) { this.class1 = class1; } /** * Returns the title. * @return String */ public String getTitle() { return title; } /** * Set the title. * @param title The title to set */ public void setTitle(String title) { this.title = title; } /** * Returns the telephone. * @return String */ public String getTelephone() { return telephone; } /** * Set the telephone. * @param telephone The telephone to set */ public void setTelephone(String telephone) { this.telephone = telephone; } /** * Returns the content. * @return String */ public String getContent() { return content; } /** * Set the content. * @param content The content to set */ public void setContent(String content) { this.content = content; } /** * Returns the name. * @return String */ public String getName() { return name; } /** * Set the name. * @param name The name to set */ public void setName(String name) { this.name = name; } public void insert() throws Exception{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn =DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=NewDB","sa","sa"); String sql="insert into info(name,title,content,telephone,class) values('"+this.name+"','"+this.title+",'"+this.content+"','"+this.telephone+"','"+this.class1+"')"; Statement stmt =conn.createStatement(); stmt.executeUpdate(sql); } } 这是actionForm中的代码 数据库中有以下几个字段:id(自动编号),name,title,content,time,modifyTime,telephone,class(是个主键约束,以它传值连接另一个表) 修改 删除 举报 引用 回复 将帖子提前 放进我的网摘 查看你的连接和SQL语句,或者是你没有执行! JSF项目 无接口 无SPRING 如何进行AOP增强 java文件中怎么不能从会话中取值 myeclipse使用Axis2插件生成wsdl文件时的错误信息,请高手帮忙看看 简单问题请教,HTTP Status 500 PDFW文件下载 急!!! 赠分40!! 关于购物车显示时遇到的问题,烦劳各位赐教! 想学习JSP(给分,在线) jsp如何调用servlet 我是新手,高手,高手,快来救我 log4j如何写combined日志格式 在线等:如何获取刚输入到表单中的值?
楼主【lwl_wm】截止到2008-07-09 16:45:16的历史汇总数据(不包括此帖):
发帖的总数量:4 发帖的总分数:40 每贴平均分数:10
回帖的总数量:3 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:2 结贴的总分数:0
无满意结贴数:2 无满意结贴分:40
未结的帖子数:2 未结的总分数:40
结贴的百分比:50.00 % 结分的百分比:0.00 %
无满意结贴率:100.00% 无满意结分率:---------------------
楼主加油
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.wm.struts.form;import java.sql.*;import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;/**
* MyEclipse Struts
* Creation date: 07-08-2008
*
* XDoclet definition:
* @struts.form name="adminInfoForm"
*/
public class AdminInfoForm extends ActionForm {
/*
* Generated fields
*/ /** class1 property */
private String class1; /** title property */
private String title; /** telephone property */
private String telephone; /** content property */
private String content; /** name property */
private String name; /*
* Generated Methods
*/ /**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
} /**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
} /**
* Returns the class1.
* @return String
*/
public String getClass1() {
return class1;
} /**
* Set the class1.
* @param class1 The class1 to set
*/
public void setClass1(String class1) {
this.class1 = class1;
} /**
* Returns the title.
* @return String
*/
public String getTitle() {
return title;
} /**
* Set the title.
* @param title The title to set
*/
public void setTitle(String title) {
this.title = title;
} /**
* Returns the telephone.
* @return String
*/
public String getTelephone() {
return telephone;
} /**
* Set the telephone.
* @param telephone The telephone to set
*/
public void setTelephone(String telephone) {
this.telephone = telephone;
} /**
* Returns the content.
* @return String
*/
public String getContent() {
return content;
} /**
* Set the content.
* @param content The content to set
*/
public void setContent(String content) {
this.content = content;
} /**
* Returns the name.
* @return String
*/
public String getName() {
return name;
} /**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
public void insert() throws Exception{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn =DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=NewDB","sa","sa");
String sql="insert into info(name,title,content,telephone,class) values('"+this.name+"','"+this.title+",'"+this.content+"','"+this.telephone+"','"+this.class1+"')";
Statement stmt =conn.createStatement();
stmt.executeUpdate(sql);
}
} 这是actionForm中的代码
数据库中有以下几个字段:id(自动编号),name,title,content,time,modifyTime,telephone,class(是个主键约束,以它传值连接另一个表)
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.wm.struts.form;
import java.sql.*; import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* MyEclipse Struts
* Creation date: 07-08-2008
*
* XDoclet definition:
* @struts.form name="adminInfoForm"
*/
public class AdminInfoForm extends ActionForm {
/*
* Generated fields
*/ /** class1 property */
private String class1; /** title property */
private String title; /** telephone property */
private String telephone; /** content property */
private String content; /** name property */
private String name; /*
* Generated Methods
*/ /**
* Method validate
* @param mapping
* @param request
* @return ActionErrors
*/
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;
} /**
* Method reset
* @param mapping
* @param request
*/
public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
} /**
* Returns the class1.
* @return String
*/
public String getClass1() {
return class1;
} /**
* Set the class1.
* @param class1 The class1 to set
*/
public void setClass1(String class1) {
this.class1 = class1;
} /**
* Returns the title.
* @return String
*/
public String getTitle() {
return title;
} /**
* Set the title.
* @param title The title to set
*/
public void setTitle(String title) {
this.title = title;
} /**
* Returns the telephone.
* @return String
*/
public String getTelephone() {
return telephone;
} /**
* Set the telephone.
* @param telephone The telephone to set
*/
public void setTelephone(String telephone) {
this.telephone = telephone;
} /**
* Returns the content.
* @return String
*/
public String getContent() {
return content;
} /**
* Set the content.
* @param content The content to set
*/
public void setContent(String content) {
this.content = content;
} /**
* Returns the name.
* @return String
*/
public String getName() {
return name;
} /**
* Set the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
public void insert() throws Exception{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn =DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DataBaseName=NewDB","sa","sa");
String sql="insert into info(name,title,content,telephone,class) values('"+this.name+"','"+this.title+",'"+this.content+"','"+this.telephone+"','"+this.class1+"')";
Statement stmt =conn.createStatement();
stmt.executeUpdate(sql);
} } 这是actionForm中的代码
数据库中有以下几个字段:id(自动编号),name,title,content,time,modifyTime,telephone,class(是个主键约束,以它传值连接另一个表)
修改 删除 举报 引用 回复
将帖子提前 放进我的网摘