import Java.sql.*;
/**
* Simple demo of how to perform a SQL query using JDBC.
**/
public class JDBC
{
public static void main(String args[]) throws Exception
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:EmpPrjDB", "admin", "letmein");
Statement stmt = conn.createStatement();
ResultSet rslt = stmt.executeQuery("SELECT name, city FROM employee");
while (rslt.next())
{
System.out.println("Hello World from "
+ rslt.getString(1) // You can use getString(columnNumber)
+ " in "
+ rslt.getString("city")); // Or, you can use getString(columnName)
}
rslt.close();
stmt.close();
conn.close();
}
}