Differences

This shows you the differences between two versions of the page.

Link to this comparison view

javaoraclejdbc [2014/10/26 01:52] (current)
Line 1: Line 1:
 +===== Java Oracl =====
 +
 +<code java>
 +// T.java
 +
 +import java.sql.*;
 +
 +public class T
 +{
 + public static void main(String args[])
 + {
 + try
 + {
 + Class.forName("​org.postgresql.Driver"​);​
 + String url = "​jdbc:​postgresql:​Learn";​
 + String user = "​postgres";​
 + String pass = "​abc123";​
 + Connection conn = DriverManager.getConnection(url,​ user, pass);
 + Statement stmt = conn.createStatement();​
 + ResultSet rs = stmt.executeQuery("​Select * from contact_info"​);​
 + System.out.println(rs.toString());​
 + ResultSetMetaData rsmd = rs.getMetaData();​
 + int numColumns = rsmd.getColumnCount();​
 + for (int i=1; i<​=numColumns;​ i++) 
 + {
 + System.out.println(
 + rsmd.getColumnLabel(i) + " : " +
 + rsmd.getColumnName(i) + " : " +
 + rsmd.getColumnTypeName(i) + " : " +
 + rsmd.getColumnDisplaySize(i) + " : " +
 + rsmd.getPrecision(i) + " : " +
 + rsmd.getScale(i)
 + );
 + }
 + }
 + catch (Exception e)
 + {
 + e.printStackTrace();​
 + System.err.println("​Exception : "+e);
 + }
 + }
 +}
 +</​code>​
 +[[start|Back to start page]]
  
javaoraclejdbc.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0