?? zzbean.java
字號:
package com.jspdev.bean;
import java.sql.*;
import javax.sql.*;
import java.util.Date;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
import java.text.SimpleDateFormat;
public class ZzBean
{
private Connection conn;
public String title="";
public String author="";
public String email="";
public String content="";
public int id;
Date pubtime= new Date();
public ZzBean()throws Exception
{
String CLASSFORNAME="oracle.jdbc.OracleDriver";
String SERVANDDB="jdbc:oracle:thin:@127.0.0.1:1521:myoracle";
String USER="admin";
String PWD="admin";
try
{
Class.forName(CLASSFORNAME);
this.conn = DriverManager.getConnection(SERVANDDB, USER, PWD);
}catch(Exception e){
e.printStackTrace();
}
}
public String getTitle()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select * from topic ");
this.title="";
while(rs.next())
{
this.title=this.title + "\n" + rs.getString("title");
}
return this.title;
}
public String getAuthor()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select author from topic");
this.author="";
while(rs.next())
{
this.author=this.author + "\n" + rs.getString("author");
}
return this.author;
}
public String getEmail()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select email from topic");
while(rs.next())
{
this.email=rs.getString("email");
}
return this.email;
}
public String getContent()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select content from topic");
while(rs.next())
{
this.content=rs.getString("content");
}
return this.content;
}
public Date getPubTime()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select pubtime from topic");
while(rs.next())
{
this.pubtime=rs.getDate("pubtime");
}
return this.pubtime;
}
public int getId()throws Exception
{
Statement my = conn.createStatement();
ResultSet rs = my.executeQuery("select id from topic");
while(rs.next())
{
this.id=rs.getInt("id");
}
return this.id;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -