⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zzbean.java

📁 公司为管理人员的java源程序
💻 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 + -