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

📄 luntandetails.java

📁 实现功能:(1)管理员由1.浏览帖子2.添加主贴3.添加复帖4.更改 5.删除6.搜索帖子的权限 (2)注册会员有1.浏览帖子2.添加主贴3添加复帖4.搜索帖子的权限 (3)游客需注册
💻 JAVA
字号:
import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;



class LunTanDetails {
  private String strSql;
  private Scanner scannerObj;
public void LunTanDetails() 
  {
      scannerObj=new Scanner(System.in);
  }
  
  public static Connection getConnection()
      throws SQLException, IOException
   {  
      Properties props = new Properties();
      FileInputStream in = new FileInputStream("database3.properties");
      props.load(in);
      in.close();

      String drivers = props.getProperty("jdbc.drivers");
      if (drivers != null) System.setProperty("jdbc.drivers", drivers);

      String url = props.getProperty("jdbc.url");
      String username = props.getProperty("jdbc.username");
      String password = props.getProperty("jdbc.password");

      return DriverManager.getConnection(url, username, password);
   }
  public  void menudisplay() throws IOException {
  	try{
    while (true) {
      Connection con=getConnection();
      strSql = "select  forumNumber,subjectName,dataTime from messagetable where messageType=-1 order by forumNumber";
      PreparedStatement pstmt = con.prepareStatement(strSql);
      ResultSet rsmain=pstmt.executeQuery();
      System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * ");
      while(rsmain.next()){
       System.out.println("  "+rsmain.getInt(1)+"\t"+rsmain.getString(2)+"\t "+rsmain.getString(3));
      }
        System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * ");
      System.out.println(" 0.增加新主题");
      System.out.println(" -1.搜索关键字");
      System.out.println("-2.跳转到登录界面");
      System.out.println("others.选择跟帖号");
      System.out.print("\n请输入您的选择...: ");
      Scanner br = new Scanner(System.in);
      int choice =br.nextInt();
      switch (choice) 
      {
        case 0:
          System.out.print("\n正在添加新主题......");
          SecondList2.fazhutie("zhanghao");
          break;
        case -1:
          Search.search();
          break;
        case -2:
           System.out.println("\n正在跳转......");
        LoadForum.forumLoadWay();   
          break;  
        default:
          strSql="select forumNumber from messagetable where messageType=-1 order by forumNumber";
          pstmt = con.prepareStatement(strSql);
          ResultSet rszhu=pstmt.executeQuery();
          while(rszhu.next()){
          	if(choice==rszhu.getInt(1)){
          		SecondList1.gentie("zhanghao",choice);//用户帐号
          		break;
          	}
          //	System.out.println("请输入一个有效数字!");
          }
          rsmain.close();
          rszhu.close();
          pstmt.close();
          con.close();
          firstList();
      }
    }
    }catch(Exception e){
    	System.out.println(e);
    }
  }
    public static void firstList() throws IOException {
      LunTanDetails luntanObj = new LunTanDetails();
      luntanObj.menudisplay();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -