Posted by anu Wed 14th Mar 2007 19:10 - Syntax is Java - 106 views
Download | New Post | Modify | Hide line numbers
  1. public getFreshData(){   
  2.     statement;
  3.     rs;
  4.     connection;
  5.     colNames=null;
  6.     data=null;
  7.    
  8.     //DATABASE CONNECTION
  9.          try{
  10.               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  11.               connection=.getConnection("jdbc:odbc:iirsdb");
  12.    
  13.             strQuery=null;
  14.             data = new ();
  15.            
  16.             //SELECT QUERIES
  17.                 if(index>=1 && index<=14)
  18.                     //strQuery="select IP_Address,"+strMapped+",Timestamp from tblStatic where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
  19.                     strQuery="select IP_Address,"+strMapped+",Timestamp from tblStatic";// where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
  20.  
  21.                 if(index>17 && index<=22)
  22.                     //strQuery="select IP_Address,"+strMapped+",Timestamp from tblSemiDyn where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
  23.                     strQuery="select IP_Address,"+strMapped+",Timestamp from tblSemiDyn";
  24.                
  25.                 if(index==25)
  26.                     //strQuery="select IP_Address,"+strMapped+",Timestamp from tblDyn where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
  27.                     strQuery="select IP_Address,"+strMapped+",Timestamp from tblDyn";
  28.        
  29.             statement=connection.createStatement();
  30.             rs=statement.executeQuery(strQuery);
  31.             rsmd=rs.getMetaData();
  32.             int col=rsmd.getColumnCount();
  33.                        
  34.             colNames=new ();
  35.                    
  36.             for(int i=1;i<=col;i++){
  37.                 colNames.addElement(rsmd.getColumnName(i));
  38.             }
  39.            
  40.             while(rs.next()){
  41.                 row=new (col);
  42.                 for(int i=1;i<=col;i++){
  43.                     row.addElement(rs.getObject(i));
  44.                 }
  45.                 data.addElement(row);
  46.             }
  47.             rs.close();
  48.             statement.close();
  49.            
  50. }catch( cnfex){
  51.             .err.println("Failed to load JDBC/ODBC driver");
  52.             cnfex.printStackTrace();
  53.         }
  54. catch ( sql){
  55.             .showMessageDialog(null, "Cannot connect to Database"+sql,"Error", .WARNING_MESSAGE);
  56. }
  57.  
  58. model = new javax.swing.table.(data,colNames);
  59. return model;
  60. }
  61.  

PermaLink to this entry https://pastebin.co.uk/11876
Posted by anu Wed 14th Mar 2007 19:10 - Syntax is Java - 106 views
Download | New Post | Modify | Hide line numbers

 

Comments: 0