Code example for Statement

Methods: executeUpdate, setQueryTimeout

0
			//open connection to DB 
			Connection con = DatabaseInteraction.connect();
			 
			Statement statement = con.createStatement(); 
		        
	        statement.setQueryTimeout(30);  // set timeout to 30 sec.
	        //insert route info to DB 
	        statement.executeUpdate("Insert INTO routes (routeName,totalNumberOfSeats) Values ( '" + routeName + "', " + totalNumberOfSeats + ")");
	        //close connection to DB 
	        DatabaseInteraction.disconnect(con);
		} 
		catch (SQLException e)
		{ 
			e.printStackTrace();
		} 
		 
	} 
}