View Single Post
  #1 (permalink)  
Old 02-01-2008, 03:12 PM
austinsmiles austinsmiles is offline
Member
 
Join Date: Feb 2008
Posts: 1
austinsmiles is on a distinguished road
Plz help ... retreiving data from an access database table....
i think there is some problem with the execute query statement.......
plz help...




import java.sql.*;
import java.io.*;

public class new2
{
public static void main(String args[])
{
if(args.length!=1)
{
System.out.println("syntax:give filename");
return;
}
java.sql.Connection conn = null;
try
{
conn=AccessJDBCUtil.getAccessDBConnection(args[0]);
Statement stmt = conn.createStatement();
ResultSet rs=null;
//stmt.execute(args[1]);
rs=stmt.executeQuery("select name2 from table1 where name1=derik");
//outputResultSet(rs);
stmt.close();
}
catch(SQLException s)
{
System.out.println(s);
}
finally
{
if(conn != null)
{
try
{
conn.close();
}
catch(SQLException ignore) {}
}
}

}
/*private static void outputResultSet(ResultSet rs) throws SQLException
{
ResultSetMetaData rsMetaData=rs.getMetaData();
int numberofcolumns=rsMetaData.getColumnCount();
while(rs.next())
{
for(int i=1; i<(numberofcolumns+1); i++)
System.out.print(rs.getString(i) + " ");
System.out.println();
}
rs.close();
}*/
}
Reply With Quote
Sponsored Links