ODBC DataSource

Have you ever heard or never connect between the Open Database Connectivity or ODBC is often called? in this article, I want to share a little knowledge of ODBC and how to connect ODBC on windows and the program code.

ODBC is In computing, Open Database Connectivity (ODBC) provides a standard software API method for using database management systems (DBMS). The designers of ODBC aimed to make it independent of programming languages, database systems, and operating systems.

Live Demo in http://ingin-bersamamu.webs.com/JDBC.pdf

(ODBC DataSource)

● Open the Control Panel
● Sign in to menu DataSource (ODBC)
● Click the Add button
● Select Driver
● Give DataSource Name
● Select Database
● Click OK

Connection to ODBC

● Create Database
● Configuring an ODBC Data Source
● Call with JDBCODBC Driver

Code Connector ODBC

● ODBC Driver Installation
– Class.forName ( “sun.jdbc.odbc.JdbcOdbcDriver”);
● Create a Connection String
– String cs = “jdbc: odbc: namadatasource”; v ● Create a connection to the database
& ndash ; Connection cn = DriverManager.getConnection (cs); v ● Create a query
– String q = “SELECT * FROM Customer”;
– Statement stm = cn.createStatement ();
● Execution
– ResultSet rs = stm.executeQuery (q);

Coding Program ODBCDemo.java

import java.sql.*;
public class ODBCDemo
public static void main(String[] args)
try {
String cs = “jdbc:odbc:shop”;
Connection cn = DriverManager.getConnection(cs);
String qry = “SELECT * FROM Customer”;
Statement stm = cn.createStatement();
ResultSet rs = stm.executeQuery(qry);v while(rs.next()) {
System.out.println(“Nama : ”+rs.getString(“Name”));
System.out.println(“Email : ”+rs.getString(“Email”));
System.out.println(“Alamat : ”+rs.getString(“Address”));
} catch (Exception err) {err.printStackTrace();}