Posted by anu Wed 14th Mar 2007 19:10 - Syntax is Java - 106 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
-
public getFreshData(){
-
statement;
-
rs;
-
connection;
-
colNames=null;
-
data=null;
-
-
//DATABASE CONNECTION
-
try{
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-
connection=.getConnection("jdbc:odbc:iirsdb");
-
-
strQuery=null;
-
data = new ();
-
-
//SELECT QUERIES
-
if(index>=1 && index<=14)
-
//strQuery="select IP_Address,"+strMapped+",Timestamp from tblStatic where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
-
strQuery="select IP_Address,"+strMapped+",Timestamp from tblStatic";// where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
-
-
if(index>17 && index<=22)
-
//strQuery="select IP_Address,"+strMapped+",Timestamp from tblSemiDyn where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
-
strQuery="select IP_Address,"+strMapped+",Timestamp from tblSemiDyn";
-
-
if(index==25)
-
//strQuery="select IP_Address,"+strMapped+",Timestamp from tblDyn where IP_Address='" + strIP + "' and Timestamp='"+strTime+"' and "+strMapped+"='"+strDetailResult+"'";
-
strQuery="select IP_Address,"+strMapped+",Timestamp from tblDyn";
-
-
statement=connection.createStatement();
-
rs=statement.executeQuery(strQuery);
-
rsmd=rs.getMetaData();
-
int col=rsmd.getColumnCount();
-
-
colNames=new ();
-
-
for(int i=1;i<=col;i++){
-
colNames.addElement(rsmd.getColumnName(i));
-
}
-
-
while(rs.next()){
-
row=new (col);
-
for(int i=1;i<=col;i++){
-
row.addElement(rs.getObject(i));
-
}
-
data.addElement(row);
-
}
-
rs.close();
-
statement.close();
-
-
}catch( cnfex){
-
.err.println("Failed to load JDBC/ODBC driver");
-
cnfex.printStackTrace();
-
}
-
catch ( sql){
-
.showMessageDialog(null, "Cannot connect to Database"+sql,"Error", .WARNING_MESSAGE);
-
}
-
-
model = new javax.swing.table.(data,colNames);
-
return model;
-
}
-
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
Download | New Post | Modify | Hide line numbers
Comments: 0