The important part of the server is database. Database for LAN based examination system will contain the number of questions which will be displayed to client and their answers, so that correct answers and clients's answers will get compared and will help to display marks.
Required Steps for database
The following steps are required to create a new Database
- Import the packages: Requires that you include the packages containing the JDBC classes needed for database programming. Most often, using import java.sql.* will suffice.
- Register the JDBC driver: Requires that you initialize a driver so you can open a communications channel with the database.
- Open a connection: Requires using the DriverManager.getConnection() method to create a Connection object, which represents a physical connection with the database server.To create a new database, you need not give any database name while preparing database URL as mentioned in the below example.
- Execute a query: Requires using an object of type Statement for building and submitting an SQL statement to the database.
- Clean up the environment . Requires explicitly closing all database resources versus relying on the JVM's garbage collection.
Psuedo code for creation of database for our project is as follows
public class Database {
Connection con;
ResultSet rs;
Database() throws ClassNotFoundException, SQLException
{
//Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver loaded successfully.....");
//con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "RUTUJA", "Rutuja123$");
System.out.println("Connection Establish.......");
}
public ArrayList<Question>fetch() throws SQLException
{
//Statement stmt = con.createStatement();
//rs=stmt.executeQuery("select * from Question");
ArrayList<Question> qset = new ArrayList<>();
// System.out.println(rs.getString(2)+rs.getString(3)+rs.getString(4)+rs.getString(5)+rs.getString(6)+rs.getString(7));
Question q = new Question("which language is fully object oriented language?","CPP","C","JAVA","None of the above","JAVA");
qset.add(q);
number of such questions....
return qset;
}
public int isvaliduser(String username,String password) throws SQLException
{
/* Statement stmt = con.createStatement();
rs=stmt.executeQuery("select * from Student");
while(rs.next())
{
System.out.println(rs.getString(2)+rs.getString(3));
if(username.equals(rs.getString(2))&& password.equals(rs.getString(3)))
{
return rs.getInt(1);
}
}*/
return 1;
}
}
Good content
ReplyDeleteThanks
DeleteNice work.....great read
ReplyDeleteGood work!
ReplyDeleteNice work good explanation
ReplyDeleteHelpful...
ReplyDeleteNice
ReplyDeleteGood job👍
ReplyDeleteNice
ReplyDeletenice
ReplyDeleteinfo is good
ReplyDeleteThanks
ReplyDeleteVery well!!
ReplyDeleteVery well!!
ReplyDeleteGood work! keep writing
ReplyDelete