hey am creating a quiz(examination) which randomly selects questions from a database,and each question has 4 options,out of which 1 is correct.....also i need to show the final result of the number of ques correctly answered,wrong and those not attempted....

im at loss at MySql...don't know how the design of the database should work out..no idea whatsoever.....

am using jdbc,prpeared statements etc etc....

please a little help with the database!!

hey,

well I'm trying to create an offline quiz using java...i have created the database...i have created the whole layout....

problem is jdbc..i have no idea how to make it work....

I'm using WAMPSERVER to create a database using MySql...have done that succesfully...now trying to connect the database to my java project and am unable to do so

ive downloaded the MySql connector( environment variable reads :" .;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;C:\mysql-connector-java-5.1.13\mysql-connector-java-5.1.13-bin.jar; " )

i have no idea what a DSN name is...i googled for some help,created a txt file DSN...

just need a small programme that shows how to connect the database to any java proggrame using jdbc.odbc.JdbcOdbc driver....
(i wanna figure out the database connection with my project bymyself)

any proggrame will do..a simple "connected" if connection is succesfull with my database will suffice...please help me!!!

Here is a good place to start: JDBC Basics

Don't use the JdbcOdbc driver when a pure JDBC driver is available.

Here are some examples specifically for MySQL: http://dev.mysql.com/doc/refman/5.1/en/connector-j-examples.html

Personally I would choose an embedded file-based database such as H2 or Derby instead of MySQL if you just want to run it locally. You don't really need a database running in a separate process.

I would suggest to save in a table, the question, the options and the correct answer as columns.
Then query the table into an ArrayList for example and randomly select an element. Use Math.random()*list.size()

Were exactly are you having problems?

well the main problem is that i have WAMPSERVER installed,,,,,i created a database....but i just dont get jdbc....i dont know how to link the database with my proggrame.....where is the database stored....no idea.... :(:(

Have you really read the above mentioned examples and tutorials and still are at a loss?

Well...regarding the connection to a MySQL database it all boils down to this:

Your database server, when started, listens to a port (by default 3306) on your PC (localhost).
The connection string for MySQL is: "jdbc:mysql://{host}:{port}/{dbname}.
So, if you wanted to connect to the database "mydb" on your server, as the user "a_user" with the password "a_password", you would use:

Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","a_user", "a_password");

If you have got mysql-connector, as you said, then you already have access to the class "com.mysql.jdbc.Driver".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.