I am using a jdbc:sqlite to access a sqlite db and get some records with a simple select statement. There are rows in the database but the java function returns nothing.
private static String ConnectionString = "jdbc:sqlite:D:\\My Documents\\NetBeansProjects\\IntelligentBusStop\\BusSystem.db";
private static ResultSet GetData(String command)
{
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try
{
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection(ConnectionString);
statement = connection.createStatement();
resultSet = statement.executeQuery(command);
return resultSet;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
try
{
resultSet.close();
statement.close();
connection.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
public static ArrayList<StopBS> GetStopBS()
{
ResultSet results = GetData("Select StopNumber, Tag, Latitude, Longitude FROM StopTable ");
ArrayList<StopBS> stops = new ArrayList<StopBS>();
try
{
while (results.next())
{
StopBS newStop = new StopBS();
newStop.StopNumber = results.getInt("StopNumber");
newStop.Tag = results.getString("Tag");
newStop.Lat = results.getFloat("Latitude");
newStop.Long = results.getFloat("Longitude");
stops.add(newStop);
}
return stops;
}
catch (Exception e)
{
e.printStackTrace();
return null ;
}
}
Using the sql statement directly on the database works. An i am using Razor sql to view the db if that makes any difference.