Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For that you need to implement JDBC.</p> <p>After creating JDBC connection. Execute query and the fetch records from the resultset. From a record you can fetch particular columns as well.</p> <p>see following example <a href="http://www.heimetli.ch/jdbc/JDBCQuery.html" rel="nofollow">how to work with jdbc basic</a></p> <p><a href="http://www.jdbc-tutorial.com/" rel="nofollow">http://www.jdbc-tutorial.com/</a></p> <pre><code>import java.sql.* ; class JDBCQuery { public static void main( String args[] ) { try { // Load the database driver Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ; // Get a connection to the database Connection conn = DriverManager.getConnection( "jdbc:odbc:Database" ) ; // Print all warnings for( SQLWarning warn = conn.getWarnings(); warn != null; warn = warn.getNextWarning() ) { System.out.println( "SQL Warning:" ) ; System.out.println( "State : " + warn.getSQLState() ) ; System.out.println( "Message: " + warn.getMessage() ) ; System.out.println( "Error : " + warn.getErrorCode() ) ; } // Get a statement from the connection Statement stmt = conn.createStatement() ; // Execute the query ResultSet rs = stmt.executeQuery( "select * from Mytable where ID in (1,2,3)" ) ; // Loop through the result set while( rs.next() ) { System.out.println( rs.getString('ID') ) ; System.out.println( rs.getString('A') ) ; System.out.println( rs.getString('B') ) ; System.out.println( rs.getString('C') ) ; } // Close the result set, statement and the connection rs.close() ; stmt.close() ; conn.close() ; } catch( SQLException se ) { System.out.println( "SQL Exception:" ) ; // Loop through the SQL Exceptions while( se != null ) { System.out.println( "State : " + se.getSQLState() ) ; System.out.println( "Message: " + se.getMessage() ) ; System.out.println( "Error : " + se.getErrorCode() ) ; se = se.getNextException() ; } } catch( Exception e ) { System.out.println( e ) ; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload