PDA

View Full Version : jav quizze engine


fol
05-09-02, 11:26
hello i am wirting a java/ quizz engine that retrieves data from a database. i got some piece of code from devx.com but unfortunately that has been written to retrieve from xml file. i am witing one to retrieve questions from oracle please help. do you have any idea where i can get source code from?

rnealejr
05-09-02, 11:59
Are you just wanting to pull records from a database using jdbc ?

fol
05-10-02, 05:53
yes and also to store in a session

rhs98
05-13-02, 11:58
So you just need help connecting to the database and getting a recordset back? It's quite easy;

try
{
//Create a connection to Oracle
Connection connection = DriverManager.getConnection("jdbc:oracle:kprb:");

//Create the statement, can scroll anyway and is updatable
Statement sel = connection.createStatement(ResultSet.TYPE_SCROLL_I NSENSITIVE, ResultSet.CONCUR_UPDATABLE);

//Execute a query and get a resultset.
resultSet = read.executeQuery("SELECT to_char(MIN("+cba_time+"), 'DD/MM/YYYY HH24:MI:SS') as x FROM " + final_table);

//loop while there's still records.
while (resultSet.next())
{
System.out.println(resultSet.getString(1));
}
}
catch (SQLException e)
{
//It all went wrong
System.out.println("Error! - " + e);
}