If you want to obtein a ResultSet with the records of the table sort by one of the colums you could try this out:
Connection con=getConnection();//getConnection() is the method where you get the connection with de Ms-Access
String sql="SELECT * FROM TABLE ORDER BY COLUMN ASC";
PreparedStatement stmt = con.prepareStatement(sql);
ResultSet rs=stmt.executeQuery();
I hope this will help,Marta
If you need the same results in different orders then have 2 ResultSets with 2 different statements.
eg.
String sql1="SELECT * FROM TABLE ORDER BY COLUMN ASC";
PreparedStatement s1 = con.prepareStatement(sql1);
ResultSet r1=s1.executeQuery();
String sql2="SELECT * FROM TABLE";
PreparedStatement s2 = con.prepareStatement(sql2);
ResultSet r2=s2.executeQuery();
the first one is sorted, the second is "as is" in the DB.
hope this helps,
Jamie
Hi,
I don't know exactly what you want to do. If you want to insert each record in some conteiner you've defined or in a text o something like that, I can give you code of how to move along the records and all the colums of each record:
while (rs.next())//rs is the ResultSet
{
Hashtable hElemento=new Hashtable();
ResultSetMetaData rsMeta=rs.getMetaData();
for (int iCont=1;iCont=rsMeta.getColumnCount()+1;iCont++)
{
String sClave=rsMeta.getColumnName(iCont);
if (rs.getObject (iCont)!=null)
{
hElemento.put (sClave, rs.getObject (iCont));//here instead of inserting the column of the
//record in a hastable you can insert it in a GUI object
}
else
{
hElemento.put (sClave, "");
}
}
}
I hope this is what you needed.MArta