我的原程序是:(绝对是正确的我择试了)我想弹出窗口,提示成功或不成,该怎么处理?//触发事件对"新用户的提交:"
void jButton1_actionPerformed(ActionEvent e) {
oEreport = new ereport();//为取出id作准备
try{
oEreport.connectToDB();//取出记录数
}
catch(Exception e1)
{
System.out.println(e1);
}
strName = this.jTextFieldnewname.getText();
floMoney = Float.valueOf(jTextFieldmoney.getText());
strType = this.jComboBoxtype.getSelectedItem().toString();
if(strType =="用户名") {
String U="U";
strType = U;
}
if( strType== "组名"){
String G="G";
strType = G;
}
ResultSet resDate = null;//为取出id作准备
try{ String strSql = "select max(\"id\") as maxnum from Savemoney";
resDate = oEreport.executeQuery(strSql);
if(resDate.next()){
iCount = resDate.getInt("maxnum");
iCount=iCount+1;
}
}
catch(Exception e1)
{
System.out.println(e1);
}
try{
//插入记录
strSql = "Insert into Savemoney "+
"Values ("+iCount+",'"+strName+"','"+strType+"',getdate(),"+floMoney +")";
System.out.println(strSql);
oEreport.executeUpdate(strSql);
}
catch(Exception e1){
System.out.println(e1);
}
}
void jButton1_actionPerformed(ActionEvent e) {
oEreport = new ereport();//为取出id作准备
try{
oEreport.connectToDB();//取出记录数
}
catch(Exception e1)
{
System.out.println(e1);
}
strName = this.jTextFieldnewname.getText();
floMoney = Float.valueOf(jTextFieldmoney.getText());
strType = this.jComboBoxtype.getSelectedItem().toString();
if(strType =="用户名") {
String U="U";
strType = U;
}
if( strType== "组名"){
String G="G";
strType = G;
}
ResultSet resDate = null;//为取出id作准备
try{ String strSql = "select max(\"id\") as maxnum from Savemoney";
resDate = oEreport.executeQuery(strSql);
if(resDate.next()){
iCount = resDate.getInt("maxnum");
iCount=iCount+1;
}
}
catch(Exception e1)
{
System.out.println(e1);
}
try{
//插入记录
strSql = "Insert into Savemoney "+
"Values ("+iCount+",'"+strName+"','"+strType+"',getdate(),"+floMoney +")";
System.out.println(strSql);
oEreport.executeUpdate(strSql);
}
catch(Exception e1){
System.out.println(e1);
}
}
解决方案 »
- 问个简单的问题。
- 初学java,请各位大侠帮忙
- 找高手做一个java题目,我是菜鸟,刚开始学JAVA.
- 各位高手,请假了,新生提问,谢谢!!
- 关于服务器Socket关闭的问题
- 十万火急!高手指点#####指点!!!!socket通信如何接收ascii码?在线等待,帮帮忙好吧?周末前一定结帖!
- 如何得到指定目录下的所有文件名字,并且存入String[]中
- up 有分,大家请进!
- DriverManager.Connect()到sql的问题。虽然分数不多,但只要问题解决就立即给!
- java里面的replace函数的用法?是不是没有replace(String source,String des)的方法!
- 用JAVA怎么编---字符敏感型的下拉菜单
- 请问apache和Tomcat有什么区别。各有什么作用?谢谢
2、搞清servlet/jsp在服务器上处理的过程然后你一定能清楚:用servlet写个javascript,由js在客户端蹦出个东西。
你觉得这个很难吗?
1。如果是用jsp程序对数据库进行操作:
写入数据后直接用脚本语言提示就行了
如:
<%
try
{
insert();
%>
<script language="vbscript">
msgbox "录入成功",64,"提示信息"
</script>
<%
}
catch(Exception e)
{
System.out.println(e);
%>
<script language="vbscript">
msgbox "录入失败",64,"提示信息"
</script>
<%
}
%>2。如果是在bean中的操作,也好办:
你在bean中的录入数据模块中,录入后
return 一个成功标记
catch中
return 一个失败标记
在jsp中
<%
if (标记为成功标记) {
%>
弹出成功对话框
<%
}
if (标记为失败标记) {
%>
弹出失败对话框
<%
}
你看行吗?
例如:
if (标记为失败标记) {
%>
弹出失败对话框
<%
return;
}
JOptionPane.showMessageDialog(bottomButton,//parentComponent
message,//message for show
title, //title of diaglog
JOptionPane.INFOMATION_MESSAGE); //mesageType
按, zzmxw(风) ,你的成功了,
我来加分