JAVA PROGRAMMING - Random Number Guessing Game - Player Logging
i was doing this Random Number Guessing Game and found out that i needed to store the username, time and date that user played, and his score.

here's the code i wrote regarding this logic im trying to create:

This is the codes for the connection:

    Connection cn=null;
    ResultSet rs=null;
    Statement stat=null;
    Statement statement=null;



The insert statement im using:

                int ok;
       	    	try
       	    	{
       	    		ok=statement.executeUpdate("INSERT INTO Table1(Player_name,Play_date, Player_score) VALUES("+'"'+username+","+datetime+","+scoretodb+'"'+")");
       	    	}catch(SQLException bleh){}


And Here's the Connection function im using:

    public void setConnection()
    	{
    		try
    		{
    			try
    			{
    				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    				cn=DriverManager.getConnection("jdbc:odbc:db1");
    				stat=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
    				rs=stat.executeQuery("Select Player_name,Play_date,Player_score from Table1");
    				rs.next();
    			}catch(ClassNotFoundException cnfe){}
    		}catch(SQLException sqle){}
    	}
JAVA PROGRAMMING - Random Number Guessing Game - Player Logging
===

i was doing this Random Number Guessing Game and found out that i needed to store the username, time and date that user played, and his score.

here's the code i wrote regarding this logic im trying to create:

This is the codes for the connection:

    Connection cn=null;
    ResultSet rs=null;
    Statement stat=null;
    Statement statement=null;



The insert statement im using:

                int ok;
       	    	try
       	    	{
       	    		ok=statement.executeUpdate("INSERT INTO Table1(Player_name,Play_date, Player_score) VALUES("+'"'+username+","+datetime+","+scoretodb+'"'+")");
       	    	}catch(SQLException bleh){}


And Here's the Connection function im using:

    public void setConnection()
    	{
    		try
    		{
    			try
    			{
    				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    				cn=DriverManager.getConnection("jdbc:odbc:db1");
    				stat=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
    				rs=stat.executeQuery("Select Player_name,Play_date,Player_score from Table1");
    				rs.next();
    			}catch(ClassNotFoundException cnfe){}
    		}catch(SQLException sqle){}
    	}