Page 1 of 1

Java connecting with an ODBC JDBC Rate Topic: -----

#1 eXceed69  Icon User is offline

  • "Super Sentai Knight Of DawN"
  • member icon

Reputation: 7
  • View blog
  • Posts: 688
  • Joined: 12-November 06

Posted 26 November 2006 - 10:56 PM

Java Database Connectivity (JDBC) supports ODBC-based databases and provides a independent database.

JDBC has four primary pieces, used for each database access phase:

DriverManager: the DriverManager class loads and configures a database driver on the database
Connection: the Connection class performs confectioning and authentication to a database

getConnection(String url)
getConnection(String url, Properties info)
getConnection(String url, String eXceed, String 12345)



The usual password and username of a database especially the oracle

 Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@mydbserver:1521:mysid","scott", "tiger" );



Statement / PreparedStatement: the Statement and PreparedStatement classes send SQL statements to the database engine for preprocessing and eventually execution
Statement createStatement()
Statement createStatement(int resultSetType, int resultSetConcurrency)



..

PreparedStatement prepareStatement(String sql)
PreparedStatement prepareStatement(String sql, 
 int resultSetType, int resultSetConcurrency)



ResultSet: the ResultSet class allows for the inspection of results from executions

	  
ResultSet rs = preparedStatement.executeQuery();




Here some sample code for you:


package com.informit.jdbc;

import java.sql.*;

public class JDBCExample {
  public static void main( String[] args ) {
   try {
	 DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
	 Connection conn = DriverManager.getConnection( 
"jdbc:oracle:thin:@mydbserver:1521:mysid",
							"exceed", "12345" ); 

	 // Create a Statement
	 PreparedStatement ps = conn.prepareStatement( 
"SELECT state FROM HomePage WHERE name = ?" );
	 ps.setString( 1, "Ronald" );

	 ResultSet rs = ps.executeQuery();
	 // Iterate through the result and print the employee names
	 while (rs.next ()) {
	  System.out.println( "State: " + rs.getString( "state" ) );
	 }
   }
   catch( Exception e ) {
	 e.printStackTrace();
   }
  }
}





here some more example links for you:

Getting Started with JDBC

Java Database Connectivity



For more example here are some links for you:
Sample Code

This post has been edited by eXceed69: 10 December 2006 - 09:10 PM


Is This A Good Question/Topic? 2
  • +

Replies To: Java connecting with an ODBC

#2 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Posted 05 December 2006 - 01:14 AM

Don't forget to make the changes, exceed69.

Good Day.
Was This Post Helpful? 0
  • +
  • -

#3 eXceed69  Icon User is offline

  • "Super Sentai Knight Of DawN"
  • member icon

Reputation: 7
  • View blog
  • Posts: 688
  • Joined: 12-November 06

Posted 08 December 2006 - 03:32 AM

just update it Born2Code..Lol
Was This Post Helpful? 0
  • +
  • -

#4 Dark_Nex  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 22-December 06

Posted 22 December 2006 - 01:47 AM

what a lovely girl....thanks for it...it will be a reference for my progress...hope see yah here :D
Was This Post Helpful? 0
  • +
  • -

#5 Ryu8146  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 22-September 10

Posted 10 January 2011 - 03:46 AM

Thanks....! im new to java... thank you for preparing this tuto.... :)
Was This Post Helpful? 0
  • +
  • -

#6 jeremejazz  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 22
  • View blog
  • Posts: 48
  • Joined: 23-April 10

Posted 11 January 2011 - 11:55 PM

Impressive.. haha .. That's +1 reputation :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1