📄 addpoll.java
字号:
package com.everstar.poll;
/**
* Title: webstar
* Description: this is the webstar project
* $ Modified Record:
* $2003.4.6: Created.
* Copyright (C) 2003 www.studyjava.com All rights reserved.
* @version 1.0
*/
import java.util.*;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.everstar.database.*;
public class AddPoll {
private PollInformation poll = null;
private String error = null;
private Database dbConn = null;
private String nextURL = null;
private int pollId = 0;
public PollInformation getPoll() { return poll;}
public void setPoll(PollInformation newPoll) { poll = newPoll;}
public void setError(String newError) { error = newError;}
public String getError() { return error;}
public Database getDbConn() { return(dbConn); }
public void setDbConn(Database newDbConn) { dbConn = newDbConn; }
public String getNextURL() { return((nextURL != null) ? nextURL : ""); }
public void setNextURL(String nextURL_) { nextURL = nextURL_; }
public void setPollId(int newPollId) { pollId = newPollId;}
public int getPollId() { return pollId;}
public void init() throws ServletException {
if (dbConn == null) error = "No Database Connection";
if (poll == null) error = "No Poll Information";
try {
String sqlstr = "select max(themeNo) + 1 from themeInfo";
ResultSet rs = dbConn.select(sqlstr);
if (rs.next()){
pollId = rs.getInt(1) ;
if(pollId < 0){
error ="Excetue error!";
}
}
rs.close();
sqlstr = "update themeInfo set status = 0, overTime = sysdate where status = 1";
dbConn.update(sqlstr);
sqlstr = "insert into themeinfo(themeNo,status,author,themeTitle,themeDetail,createTime) values( " +
pollId + ",1,'" + poll.getAuthor() + "','" + poll.getThemeTitle() + "','" + poll.getThemeDetail() +
"',sysdate)";
dbConn.insert(sqlstr);
} catch (Exception e) {
error = "SQL Error";
}
}
public AddPoll() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -