@@ -0,0 +1,1948 @@
+// Pre-generated code, not written by me.%0A%0A//STEP 1. Import required packages%0Aimport java.sql.*;%0A%0Apublic class Exercise1_FirstExample %7B%0A   // JDBC driver name and database URL%0A   static final String JDBC_DRIVER = %22com.mysql.jdbc.Driver%22;  %0A   static final String DB_URL = %22jdbc:mysql://srv.iits.uni-ruse.bg/db53%22;%0A%0A   //  Database credentials%0A   static final String USER = %22inf53%22;%0A   static final String PASS = %22inf53pass%22;%0A   %0A   public static void main(String%5B%5D args) %7B%0A%09   Connection conn = null;%0A%09   Statement stmt = null;%0A%09   try%7B%0A%09      //STEP 2: Register JDBC driver%0A%09      Class.forName(%22com.mysql.jdbc.Driver%22);%0A%09%0A%09      //STEP 3: Open a connection%0A%09      System.out.println(%22Connecting to database...%22);%0A%09      conn = DriverManager.getConnection(DB_URL,USER,PASS);%0A%09%0A%09      //STEP 4: Execute a query%0A%09      System.out.println(%22Creating statement...%22);%0A%09      stmt = conn.createStatement();%0A%09      String sql;%0A%09      sql = %22SELECT ID FROM Test%22;%0A%09      ResultSet rs = stmt.executeQuery(sql);%0A%09%0A%09      //STEP 5: Extract data from result set%0A%09      while(rs.next())%7B%0A%09         //Retrieve by column name%0A%09         int id  = rs.getInt(%22ID%22);%0A%09%0A%09         //Display values%0A%09         System.out.println(%22ID: %22 + id);%0A%09         %0A%09      %7D%0A%09      //STEP 6: Clean-up environment%0A%09      rs.close();%0A%09      stmt.close();%0A%09      conn.close();%0A%09   %7Dcatch(SQLException se)%7B%0A%09      //Handle errors for JDBC%0A%09      se.printStackTrace();%0A%09   %7Dcatch(Exception e)%7B%0A%09      //Handle errors for Class.forName%0A%09      e.printStackTrace();%0A%09   %7Dfinally%7B%0A%09      //finally block used to close resources%0A%09      try%7B%0A%09         if(stmt!=null)%0A%09            stmt.close();%0A%09      %7Dcatch(SQLException se2)%7B%0A%09      %7D// nothing we can do%0A%09      try%7B%0A%09         if(conn!=null)%0A%09            conn.close();%0A%09      %7Dcatch(SQLException se)%7B%0A%09         se.printStackTrace();%0A%09      %7D//end finally try%0A%09   %7D//end try%0A%09   System.out.println(%22Goodbye!%22);%0A%09%7D//end main%0A%7D//end FirstExample%0A

Create Exercise1_FirstExample.java