A Gentle Introduction to

SQL

We use can connect to an SQL engine using JDBC. You will need to obtain a JDBC driver from the appropriate database. googleUtilizamos podemos conectar con un motor del SQL que usa a JDBC. You necesitaremos obtener un conductor de JDBC de la base de datos apropiada.

You need to compile and execute the java from the command prompt: googleUsted necesita compilar y ejecutar la Java del aviso de comando:

javac CIA.java
java -classpath "C:/thingies/mysql-connector-java-2.0.14;." CIA
/* CIA.java
   From https://sqlpass-latam.org By Andrew Cumming
*/
import java.sql.*;
public class CIA{
  public static void main(String[] args){
    Connection myCon;
    Statement myStmt;
    try{
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      // Connect to an instance of mysql with the follow details:
      // machine address: pc236nt.napier.ac.uk
      // database       : gisq
      // user name      : scott
      // password       : tiger
      myCon = DriverManager.getConnection(
              "jdbc:mysql://pc236nt.napier.ac.uk/gisq",
              "scott","tiger");
      myStmt = myCon.createStatement();
      ResultSet result = myStmt.executeQuery(
         "SELECT * FROM cia WHERE population>200000000");
      while (result.next()){
        System.out.println(result.getString("name"));
      }
      myCon.close();
    }
    catch (Exception sqlEx){
      System.err.println(sqlEx);
    }
  }
}

It should respond with the names of four countries.googleDebe responder con los nombres de cuatro países.