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

📄 polyrecord.java

📁 主要为一个空间信息管理系统
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package edu.whu.poly;
import edu.whu.database.ConnectionPooling;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.Date;
import java.sql.DatabaseMetaData;
import java.util.List;
import java.util.ArrayList;
import java.lang.Object;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class polyRecord
{
  Connection conn;
  public polyRecord(String homeDirectory)
  {
    ConnectionPooling.setHomeDirectory(homeDirectory);
    conn=ConnectionPooling.getConnection();
  }
  public polyStruct[] Read(String tablename,String coordinate)
  {
    polyStruct[] polyDate=null;
    polyStruct polyTempDate;
    int[] x=null;
    int[] y=null;
    String projectName;
    int polyNumber=0;
    int pointNumber=0;
    int CountNumber = 0;
    String constract = null;
    String file = null;
    String projectnum = null;
    String name = null;
    String transaction = null;
    String unit = null;
    String man1 = null;
    String man2 = null;
    String man3 = null;
    String originaldata = null;
    String claritymap = null;
    String projectsize = null;
    String projectaddress = null;
    String industry = null;
    String remark = null;
    String filePath1=null;
    String filePath2=null;
    String filePath3=null;
    String projectMan=null;
    Date projectTime=null;
    String coordinate1=null;
    String eposition1=null;
    String sqlcmd_c = "SELECT COUNT(*) FROM "+tablename+" WHERE COORDINATE= '"+coordinate+"' group by NAME";
    String sqlcmd = "SELECT * FROM "+tablename+" WHERE COORDINATE= '"+coordinate+"' group by NAME";
    try
    {
      ResultSet rs_c = conn.createStatement().executeQuery(sqlcmd_c);
      ResultSet rs = conn.createStatement().executeQuery(sqlcmd);
      while(rs_c.next())
      {
        CountNumber++;
      }
      //System.out.println(CountNumber);
      polyDate = new polyStruct[CountNumber];
      int RolNumber=0;
      int i=0;
      while(rs.next())
      {
        name = rs.getString("NAME");
       if (rs.getString("CONSTRACT") != null)
       {
         constract = rs.getString("CONSTRACT");
       }
       if (rs.getString("FILE") != null)
       {
         file = rs.getString("FILE");
       }
       if (rs.getString("PROJECTNUM") != null)
       {
         projectnum = rs.getString("PROJECTNUM");
       }
       if (rs.getString("TRANSACTION") != null)
       {
         transaction = rs.getString("TRANSACTION");
       }
       if (rs.getDate("TIME") != null)
       {
         projectTime = rs.getDate("TIME");
       }
       if (rs.getString("UNIT") != null)
       {
         unit = rs.getString("UNIT");
       }
       if (rs.getString("MAN1") != null)
       {
         man1 = rs.getString("MAN1");
       }
       if (rs.getString("MAN2") != null)
       {
         man2 = rs.getString("MAN2");
       }
       if (rs.getString("MAN3") != null)
       {
         man3 = rs.getString("MAN3");
       }
       if (rs.getString("ORIGINALDATA") != null)
       {
         originaldata = rs.getString("ORIGINALDATA");
       }
       if (rs.getString("CLARITYMAP") != null)
       {
         claritymap = rs.getString("CLARITYMAP");
       }
       if (rs.getString("PROJECTSIZE") != null)
       {
         projectsize = rs.getString("PROJECTSIZE");
       }
       if (rs.getString("PROJECTADDRESS") != null)
       {
         projectaddress = rs.getString("PROJECTADDRESS");
       }
       if (rs.getString("INDUSTRY") != null)
       {
         industry = rs.getString("INDUSTRY");
       }
       if (rs.getString("REMARK") != null)
       {
         remark = rs.getString("REMARK");
       }
       if (rs.getString("COORDINATE") != null)
       {
         coordinate1 = rs.getString("COORDINATE");
       }


        String sqlcmd2_c="SELECT COUNT(*) FROM "+tablename+" where NAME ='"+name+"' AND COORDINATE= '"+coordinate+"' order by NUMBER";
        String sqlcmd2="SELECT * FROM "+tablename+" where NAME ='"+name+"' AND COORDINATE= '"+coordinate+"' order by NUMBER";
        ResultSet rs2_c=conn.createStatement().executeQuery(sqlcmd2_c);
        ResultSet rs2=conn.createStatement().executeQuery(sqlcmd2);
        int RolNumber2=0;
        int j=0;
        if(rs2_c.next())
        {
          pointNumber=rs2_c.getInt(1);
          //System.out.println("pointNumber="+pointNumber);
          polyTempDate=new polyStruct(pointNumber);
        }
        else
        {
          polyTempDate=null;
        }
        while(rs2.next())
        {

          x = new int[pointNumber];
          y = new int[pointNumber];
          polyTempDate.polyX[j]=Integer.parseInt(rs2.getString("X"));
          polyTempDate.polyY[j]=Integer.parseInt(rs2.getString("Y"));
          System.out.println(polyTempDate.polyX[j]+" x"+j);
          System.out.println(polyTempDate.polyY[j]+" y"+j);
          j++;
        }
        polyTempDate.name = name;
       polyTempDate.constract = constract;
       polyTempDate.file = file;
       polyTempDate.projectnum = projectnum;
       polyTempDate.transaction =transaction;
       polyTempDate.unit = unit;
       polyTempDate.man1 = man1;
       polyTempDate.man2 = man2;
       polyTempDate.man3 = man3;
       polyTempDate.originaldata = originaldata;
       polyTempDate.claritymap = claritymap;
       polyTempDate.projectsize = projectsize;
       polyTempDate.projectaddress = projectaddress;
       polyTempDate.industry = industry;
       polyTempDate.remark = remark;
       polyTempDate.coordinate = coordinate1;
       polyTempDate.time = projectTime;
       polyTempDate.projectnum=projectnum;

        polyDate[i]=polyTempDate;
        i++;
        rs2.close();
        rs2_c.close();
      }
      //System.out.println(polyDate.length);

      for(int k=0;k<polyDate.length;k++)
      {

        if(polyDate[k]!=null)
        {
          //System.out.println(polyDate[k].projectName);
          for(int l=0;l<polyDate[k].getX().length;l++)
          {
            //System.out.println(polyDate[k].getX()[l]);
            //System.out.println("length="+polyDate[k].getX().length);
          }
          for(int u=0;u<polyDate[k].getY().length;u++)
          {
            //System.out.println(polyDate[k].getY()[u]);
          }

        }
      }
      //test_paint p=new test_paint(polyDate);
      //polyProcess p1=new polyProcess();
      //p1.test_RgnAndRgn(polyDate[0],polyDate[1]);
      rs.close();
      rs_c.close();
    }
    catch (Exception e1)
    {
      e1.printStackTrace();
    }

    return polyDate;
  }
  public polyStruct[] polyRecord_ReadFromSql(String sql,String tablename)
  {
   polyStruct[] polyDate=null;
   polyStruct polyTempDate;
   int[] x=null;
   int[] y=null;
   String projectName;
   int polyNumber=0;
   int pointNumber=0;
   int CountNumber=0;
   int projectNumber=0;
   String filePath1=null;
   String filePath2=null;
   String filePath3=null;
   String projectMan=null;
   Date projectTime=null;
   String coordinate1=null;
   String eposition1=null;
   String constract = null;
   String file = null;
   String projectnum = null;
   String name = null;
   String transaction = null;
   String unit = null;
   String man1 = null;
   String man2 = null;
   String man3 = null;
   String originaldata = null;
   String claritymap = null;
   String projectsize = null;
   String projectaddress = null;
   String industry = null;
   String remark = null;
   String coordinate=null;
   String sqlcmd_c = "SELECT COUNT(*) FROM "+tablename+sql+" group by PROJECTNUM";
   String sqlcmd = "SELECT * FROM "+tablename+sql+" group by PROJECTNUM";
   try
   {
     ResultSet rs_c = conn.createStatement().executeQuery(sqlcmd_c);
     ResultSet rs = conn.createStatement().executeQuery(sqlcmd);
     while(rs_c.next())
     {
       CountNumber++;
     }
     //System.out.println(CountNumber);
     polyDate = new polyStruct[CountNumber];
     int RolNumber=0;
     int i=0;
     while (rs.next())
     {

       name = rs.getString("NAME");
       if (rs.getString("CONSTRACT") != null)
       {
         constract = rs.getString("CONSTRACT");
       }
       if (rs.getString("FILE") != null)
       {
         file = rs.getString("FILE");
       }
       if (rs.getString("PROJECTNUM") != null)
       {
         projectnum = rs.getString("PROJECTNUM");
       }
       if (rs.getString("TRANSACTION") != null)
       {
         transaction = rs.getString("TRANSACTION");
       }
       if (rs.getDate("TIME") != null)
       {
         projectTime = rs.getDate("TIME");
       }
       if (rs.getString("UNIT") != null)
       {
         unit = rs.getString("UNIT");
       }
       if (rs.getString("MAN1") != null)
       {
         man1 = rs.getString("MAN1");
       }
       if (rs.getString("MAN2") != null)
       {
         man2 = rs.getString("MAN2");
       }
       if (rs.getString("MAN3") != null)
       {
         man3 = rs.getString("MAN3");
       }
       if (rs.getString("ORIGINALDATA") != null)
       {
         originaldata = rs.getString("ORIGINALDATA");
       }
       if (rs.getString("CLARITYMAP") != null)
       {
         claritymap = rs.getString("CLARITYMAP");
       }
       if (rs.getString("PROJECTSIZE") != null)
       {
         projectsize = rs.getString("PROJECTSIZE");
       }
       if (rs.getString("PROJECTADDRESS") != null)
       {
         projectaddress = rs.getString("PROJECTADDRESS");
       }
       if (rs.getString("INDUSTRY") != null)
       {
         industry = rs.getString("INDUSTRY");
       }
       if (rs.getString("REMARK") != null)
       {
         remark = rs.getString("REMARK");
       }
       if (rs.getString("COORDINATE") != null)
       {
         coordinate = rs.getString("COORDINATE");
       }
       String sqlcmd2_c="SELECT COUNT(*) FROM "+tablename+sql+" order by NUMBER";
       String sqlcmd2="SELECT * FROM "+tablename+sql+" order by NUMBER";
       ResultSet rs2_c=conn.createStatement().executeQuery(sqlcmd2_c);
       ResultSet rs2=conn.createStatement().executeQuery(sqlcmd2);
       int RolNumber2=0;
       int j=0;
       if(rs2_c.next())
       {
         pointNumber=rs2_c.getInt(1);
         //System.out.println("pointNumber="+pointNumber);
         polyTempDate=new polyStruct(pointNumber);
       }
       else
       {
         polyTempDate=null;
       }
       while(rs2.next())
       {

         x = new int[pointNumber];
         y = new int[pointNumber];
         polyTempDate.polyX[j]=Integer.parseInt(rs2.getString("X"));
         polyTempDate.polyY[j]=Integer.parseInt(rs2.getString("Y"));
         System.out.println(polyTempDate.polyX[j]+" x"+j);
         System.out.println(polyTempDate.polyY[j]+" y"+j);
         j++;
       }
       polyTempDate.name = name;
       polyTempDate.constract = constract;
       polyTempDate.file = file;
       polyTempDate.projectnum = projectnum;
       polyTempDate.transaction =transaction;
       polyTempDate.unit = unit;
       polyTempDate.man1 = man1;
       polyTempDate.man2 = man2;
       polyTempDate.man3 = man3;
       polyTempDate.originaldata = originaldata;
       polyTempDate.claritymap = claritymap;
       polyTempDate.projectsize = projectsize;
       polyTempDate.projectaddress = projectaddress;
       polyTempDate.industry = industry;
       polyTempDate.remark = remark;
       polyTempDate.coordinate = coordinate;
       polyTempDate.time = projectTime;
       polyTempDate.projectnum=projectnum;
       polyDate[i]=polyTempDate;
       i++;
       rs2.close();
       rs2_c.close();
     }
     //System.out.println(polyDate.length);

     for(int k=0;k<polyDate.length;k++)
     {

       if(polyDate[k]!=null)
       {
         //System.out.println(polyDate[k].projectName);
         for(int l=0;l<polyDate[k].getX().length;l++)
         {
           //System.out.println(polyDate[k].getX()[l]);
           //System.out.println("length="+polyDate[k].getX().length);
         }
         for(int u=0;u<polyDate[k].getY().length;u++)
         {
           //System.out.println(polyDate[k].getY()[u]);
         }

       }
     }
     //test_paint p=new test_paint(polyDate);
     //polyProcess p1=new polyProcess();
     //p1.test_RgnAndRgn(polyDate[0],polyDate[1]);
     rs.close();
     rs_c.close();
   }
   catch (Exception e1)
   {
     e1.printStackTrace();
   }

   return polyDate;

  }
  public boolean polyRecord_UpdateFromProjectNumber(polyStruct polyDate,String tablename)
  {
    if(Delete(polyDate.getProjectNumber(),tablename))
    {
      for(int i=0;i<polyDate.getX().length;i++)
      {
        recordStruct record=new recordStruct(polyDate.getProjectNumber(),polyDate.getProjectName(),polyDate.getX()[i]+"",polyDate.getY()[i]+"",polyDate.getFilePath1(),polyDate.getFilePath2(),polyDate.getFilePath3(),polyDate.getProjectMan(),polyDate.getCoordinate(),polyDate.getEposition(),polyDate.getDate());
        if(Insert(record,tablename))
        {
          System.out.println(i+"record"+"ok");
        }
      }
      return true;
    }
    return  false;

  }

  public polyStruct[] polyRecord_ReadProper(String sql,String tablename)
  {
    polyStruct[] polyDate = null;
    polyStruct polyTempDate;
    int[] x = null;
    int[] y = null;
    String projectName;
    int polyNumber = 0;
    int pointNumber = 0;
    int CountNumber = 0;
    String filePath1 = null;
    String filePath2 = null;
    String filePath3 = null;
    String constract = null;
    String file = null;
    String projectnum = null;
    String name = null;
    String transaction = null;
    String unit = null;
    String man1 = null;
    String man2 = null;
    String man3 = null;
    String originaldata = null;
    String claritymap = null;
    String projectsize = null;
    String projectaddress = null;
    String industry = null;
    String remark = null;
    String projectMan = null;
    Date projectTime = null;
    String coordinate=null;
    String eposition=null;
    String sqlcmd_c =
        "SELECT COUNT(*) FROM "+tablename+sql+" group by NAME";

⌨️ 快捷键说明

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