|
Re: Major Problem!!!
|
Posted: Oct 4, 2005 5:10 AM
|
|
Example something like this would be the heart and soul of the application:
public void dumpResultSet(ResultSet rs, String table){
StringBuffer insertStr = new StringBuffer("insert into "+table+"(");
while(rs.next()){
ResultSetMetaData rsmd = rs.getMetaData();
int numCols = rsmd.getColumnCount();
int i = 0;
while(i < numCols){
insertStr.append(rsmd.getColumnName(i)+", ");
}
// then eliminate the last "," at the end of the buffer
// - I'm too lazy to go through the StringBuffer API and figure this out
insertStr.append(")values(");
i = 0;
while(i < numCols){
String colType = rsmd.getColumnTypeName(i);
if(colTypeName.equals("text");
insertStr.append("'"+rs.getString()+"',");
else if(colTypeName.equals("integer"))
insertStr.append("rs.getInt(),");
// Continue with however many types are possible in
// normal SQL
}
// When done remove the last char which is will be ","
// - I'm too lazy to go through the StringBuffer API and figure this out
// Obviouosly getPostgresConnection() is a method that returns the
// to connection defined
insertStr.append(")");
PreparedStatement pstmt = getPostgresConnection().preparedStatement(insertStr.toString());
}
}
// You have a similar method somewhere that returns the ResultSet from you MSAccess database
public ResultSet getMSAccessResultSet(String table){
// do neccessary stuff via SQL Select * from table, etc...
return result;
}
Then create your GUI, and inconjunction with whatever class you want your Controller to be.
Good luck again, Kondwani
|
|