JDBC is an API that allows Java programs to connect to databases. It provides methods for establishing connections, executing SQL statements, and processing result sets. The key steps for using JDBC are to establish a connection, create statements, execute SQL, get result sets, and close connections. JDBC supports accessing metadata about the database schema and result sets.
The document discusses the Java Database Connectivity (JDBC) API for accessing tabular data sources like relational databases from Java code. It provides steps for connecting to an Oracle database using JDBC, executing SQL statements to retrieve and manipulate data, handling transactions, and obtaining metadata about the database. Key classes in JDBC include Connection, Statement, and ResultSet. The multi-tier architecture of JDBC separates the data access logic from the business logic and user interface.
JDBC (Java Database Connectivity) is an API that allows Java programs to connect to databases. The basic steps to use a database in Java are: 1) establish a connection, 2) create JDBC statements, 3) execute SQL statements, 4) get the ResultSet, and 5) close connections. JDBC allows transactions to be performed and exceptions to be handled. It provides metadata about the database structure and ResultSet.
The document discusses the Java Database Connectivity (JDBC) API, which allows Java programs to connect to databases. It describes the basic steps to connect to a database, execute SQL statements, and retrieve and process result sets. It also covers transaction handling, metadata retrieval, and scrollable/updatable result sets.
JDBC is an API that allows Java programs to connect to databases. It provides methods for establishing a connection, executing SQL statements, and retrieving results. The basic steps are to load a database driver, connect to the database, create statements to send queries and updates, get result sets, and close connections. JDBC supports accessing many types of data sources and provides metadata about the database schema.
The document discusses Java Database Connectivity (JDBC) and how it allows Java code to execute SQL statements inside relational databases. It covers the JDBC API and how it provides a standard interface to different databases. It also discusses the JDBC-ODBC bridge which allows Java code to access databases via ODBC. The document provides an example of JDBC code to connect to a database, execute a query, and access the result set. It discusses using connection pooling and JNDI lookups in J2EE applications to connect to databases.
JDBC provides an API for accessing databases from Java that simplifies development, supports metadata access, and allows connection pooling. It includes interfaces for application writers and driver writers, with popular drivers available for databases like Oracle, MySQL, and SQL Server. JDBC drivers can be Type 1 (JDBC-ODBC bridge), Type 2 (partial JDBC), Type 3 (pure Java for middleware), or Type 4 (direct connection).
The document provides information about Java Database Connectivity (JDBC). It discusses what JDBC is, the prerequisites for using JDBC, how to set up the JDBC environment, and the steps to create a basic JDBC application. It also covers extracting data from result sets, handling SQL exceptions, JDBC data types, and examples for creating and selecting a database using JDBC.
This document provides an overview of connecting to and interacting with a CSQL database using JDBC. It discusses loading the JDBC driver, establishing a connection, and executing SQL statements like CREATE, INSERT, UPDATE, DELETE, and DROP using Statement and PreparedStatement objects. Example code is provided to demonstrate connecting to CSQL and performing common SQL operations through JDBC.
The document discusses the Java Database Connectivity (JDBC) API for accessing tabular data sources like relational databases from Java code. It provides steps for connecting to an Oracle database using JDBC, executing SQL statements to retrieve and manipulate data, handling transactions, and obtaining metadata about the database. Key classes in JDBC include Connection, Statement, and ResultSet. The multi-tier architecture of JDBC separates the data access logic from the business logic and user interface.
JDBC (Java Database Connectivity) is an API that allows Java programs to connect to databases. The basic steps to use a database in Java are: 1) establish a connection, 2) create JDBC statements, 3) execute SQL statements, 4) get the ResultSet, and 5) close connections. JDBC allows transactions to be performed and exceptions to be handled. It provides metadata about the database structure and ResultSet.
The document discusses the Java Database Connectivity (JDBC) API, which allows Java programs to connect to databases. It describes the basic steps to connect to a database, execute SQL statements, and retrieve and process result sets. It also covers transaction handling, metadata retrieval, and scrollable/updatable result sets.
JDBC is an API that allows Java programs to connect to databases. It provides methods for establishing a connection, executing SQL statements, and retrieving results. The basic steps are to load a database driver, connect to the database, create statements to send queries and updates, get result sets, and close connections. JDBC supports accessing many types of data sources and provides metadata about the database schema.
The document discusses Java Database Connectivity (JDBC) and how it allows Java code to execute SQL statements inside relational databases. It covers the JDBC API and how it provides a standard interface to different databases. It also discusses the JDBC-ODBC bridge which allows Java code to access databases via ODBC. The document provides an example of JDBC code to connect to a database, execute a query, and access the result set. It discusses using connection pooling and JNDI lookups in J2EE applications to connect to databases.
JDBC provides an API for accessing databases from Java that simplifies development, supports metadata access, and allows connection pooling. It includes interfaces for application writers and driver writers, with popular drivers available for databases like Oracle, MySQL, and SQL Server. JDBC drivers can be Type 1 (JDBC-ODBC bridge), Type 2 (partial JDBC), Type 3 (pure Java for middleware), or Type 4 (direct connection).
The document provides information about Java Database Connectivity (JDBC). It discusses what JDBC is, the prerequisites for using JDBC, how to set up the JDBC environment, and the steps to create a basic JDBC application. It also covers extracting data from result sets, handling SQL exceptions, JDBC data types, and examples for creating and selecting a database using JDBC.
This document provides an overview of connecting to and interacting with a CSQL database using JDBC. It discusses loading the JDBC driver, establishing a connection, and executing SQL statements like CREATE, INSERT, UPDATE, DELETE, and DROP using Statement and PreparedStatement objects. Example code is provided to demonstrate connecting to CSQL and performing common SQL operations through JDBC.
The document discusses Java Database Connectivity (JDBC) which allows Java applications to connect to databases. It describes the JDBC architecture including drivers, loading drivers, connecting to databases, executing queries and updates using Statement and PreparedStatement objects, processing result sets, and handling exceptions. It also covers transactions, result set metadata, and cleaning up resources.
JDBC is a Java API that provides interfaces for connecting to and working with databases. It allows Java applications to execute SQL statements and process the results by providing a standard interface for database access that is independent of database vendors. The key classes and interfaces in JDBC include Connection, Statement, PreparedStatement, CallableStatement, and ResultSet. JDBC drivers convert JDBC calls into database-specific protocols to communicate with the database.
JDBC stands for Java Database Connectivity and is an API that allows Java programs to execute SQL statements and retrieve results from a database. It uses JDBC drivers to connect to different database types and provides interfaces for establishing a connection, executing queries, and processing result sets. Some common uses of JDBC include building Java applications, applets, servlets, and JSPs that need to access and manipulate data stored in relational databases.
JDBC provides a standard interface for communication between Java programs and SQL databases, allowing Java programs to execute SQL statements and process the results. It requires loading a JDBC driver, establishing a connection to the database, executing SQL statements via that connection, and processing any results. The document outlines the key JDBC classes, interfaces, and steps for connecting to a database, executing statements, and retrieving and using the results.
The document discusses connecting Java applications to MS Access and MySQL databases using JDBC. It provides code examples to demonstrate loading drivers, establishing connections, executing queries, retrieving results, and closing connections for basic CRUD (create, read, update, delete) operations. It also covers differences between Statement and PreparedStatement interfaces and using stored procedures with CallableStatement.
This document provides an overview of using JDBC (Java Database Connectivity) to connect Java applications to relational databases. It discusses downloading and configuring the JDBC driver, executing SQL statements to query and manipulate data, processing result sets, and properly closing connections. Transactions are also introduced to group statements and ensure all succeed or fail together.
Introduction to JDBC and database access in web applicationsFulvio Corno
Introduction to the JDBC standard and best practices for database access from Web Applications.
Materiale realizzato per il corso di Sistemi Informativi Aziendali del Politecnico di Torino - http://bit.ly/sistinfo
This document discusses using JDBC to access databases from Java applications like JSP pages. It covers loading the appropriate JDBC driver, establishing a connection with the database using a connection URL, executing SQL statements using Statement objects to retrieve and process result sets, and closing the connection when done. The core steps are to load the driver, get a connection, create statements, execute queries/updates, process results, and close the connection.
This document discusses using JDBC to access databases from Java applications like JSP pages. It covers loading the appropriate JDBC driver, establishing a connection with the database using a connection URL, executing SQL statements using Statement objects to retrieve and process result sets, and closing the connection when done. The core steps are to load the driver, get a connection, create statements, execute queries/updates, process results, and close the connection.
This document provides an overview of using Java Database Connectivity (JDBC) to connect to and interact with relational databases from Java servlets. It describes relational databases and how they organize data into tables. It explains the basic JDBC connection flow of getting a connection, executing SQL statements, and reading results. It also covers key JDBC interfaces like Connection, Statement, and ResultSet. The document provides an example servlet for looking up phone numbers from a database and discusses best practices like reusing connections and using connection pooling.
This document provides an overview of Java Database Connectivity (JDBC) and how to use it. It discusses how JDBC works by registering drivers, connecting to databases, and executing SQL statements. It also provides steps for configuring JDBC with Eclipse and Microsoft SQL Server, including downloading drivers and copying files. Examples are given for creating tables, executing queries with the Statement interface, and fetching data from the ResultSet. The document concludes by demonstrating how to properly close resources.
This document discusses Java Database Connectivity (JDBC) and provides details on connecting to a database from a Java application. There are 4 types of JDBC drivers that enable connection. Connecting involves 5 steps - registering the driver class, creating a connection, creating a statement, executing queries, and closing the connection. Examples are provided for connecting to MySQL and MS Access databases.
This document provides an overview of JDBC (Java Database Connectivity) and the different types of JDBC drivers. It discusses the four types of JDBC drivers: Type 1 (JDBC-ODBC bridge), Type 2 (JDBC-Native API), Type 3 (JDBC-Net pure Java), and Type 4 (100% pure Java). It describes the characteristics of each driver type and when each might be used. The document also covers basic JDBC concepts like establishing a database connection, executing statements, and retrieving result sets.
JDBC provides a standard interface for connecting to relational databases from Java applications. It establishes a connection by loading a JDBC driver, then executing SQL statements using objects like Statement and PreparedStatement. Results are retrieved into a ResultSet which can be processed row-by-row. Finally, connections are closed to release resources.
The document discusses using JDBC (Java Database Connectivity) for object-relational mapping in Java. It covers connecting to databases, executing SQL statements and queries, working with ResultSets, and best practices for managing database connections. Key points include using the DriverManager class to obtain database connections, preparing statements for parameterized queries, and implementing a DAO (Data Access Object) layer to encapsulate data access logic.
In this core java training session, you will learn JDBC Cont. Topics covered in this session are:
• JDBC Continued
• Introduction to Java Enterprise Edition (Java EE)
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
This document provides an overview of using JDBC (Java Database Connectivity) to access databases from Java applications. It covers the main JDBC concepts like drivers, connections, statements, result sets, and transactions. It also describes the typical steps for querying and updating databases using JDBC: establishing a connection, creating statements, executing SQL statements, processing result sets, and closing resources. The document includes examples for connecting to Oracle and ODBC databases and using prepared statements. It discusses best practices like using connection pools, tuning transactions, and optimizing SQL queries.
The document discusses several JDBC APIs used for connecting Java applications to databases. The Connection interface is used to create a connection to a database and execute SQL statements. The Statement interface executes static SQL queries and retrieves results. The PreparedStatement interface executes dynamic queries with IN parameters by using placeholder values set using methods like setInt() and setString(). Examples of using these interfaces will be provided in subsequent chapters.
This document provides an overview of Spring's transaction management capabilities. It discusses how Spring provides a uniform transaction management API that can work with various transaction technologies like JDBC, Hibernate, JPA etc. It also describes how transactions can be handled programmatically using the TransactionTemplate or directly through the transaction manager. Finally, it covers Spring's declarative transaction support using XML or annotations.
The document discusses Java Database Connectivity (JDBC) which allows Java applications to connect to databases. It describes the JDBC architecture including drivers, loading drivers, connecting to databases, executing queries and updates using Statement and PreparedStatement objects, processing result sets, and handling exceptions. It also covers transactions, result set metadata, and cleaning up resources.
JDBC is a Java API that provides interfaces for connecting to and working with databases. It allows Java applications to execute SQL statements and process the results by providing a standard interface for database access that is independent of database vendors. The key classes and interfaces in JDBC include Connection, Statement, PreparedStatement, CallableStatement, and ResultSet. JDBC drivers convert JDBC calls into database-specific protocols to communicate with the database.
JDBC stands for Java Database Connectivity and is an API that allows Java programs to execute SQL statements and retrieve results from a database. It uses JDBC drivers to connect to different database types and provides interfaces for establishing a connection, executing queries, and processing result sets. Some common uses of JDBC include building Java applications, applets, servlets, and JSPs that need to access and manipulate data stored in relational databases.
JDBC provides a standard interface for communication between Java programs and SQL databases, allowing Java programs to execute SQL statements and process the results. It requires loading a JDBC driver, establishing a connection to the database, executing SQL statements via that connection, and processing any results. The document outlines the key JDBC classes, interfaces, and steps for connecting to a database, executing statements, and retrieving and using the results.
The document discusses connecting Java applications to MS Access and MySQL databases using JDBC. It provides code examples to demonstrate loading drivers, establishing connections, executing queries, retrieving results, and closing connections for basic CRUD (create, read, update, delete) operations. It also covers differences between Statement and PreparedStatement interfaces and using stored procedures with CallableStatement.
This document provides an overview of using JDBC (Java Database Connectivity) to connect Java applications to relational databases. It discusses downloading and configuring the JDBC driver, executing SQL statements to query and manipulate data, processing result sets, and properly closing connections. Transactions are also introduced to group statements and ensure all succeed or fail together.
Introduction to JDBC and database access in web applicationsFulvio Corno
Introduction to the JDBC standard and best practices for database access from Web Applications.
Materiale realizzato per il corso di Sistemi Informativi Aziendali del Politecnico di Torino - http://bit.ly/sistinfo
This document discusses using JDBC to access databases from Java applications like JSP pages. It covers loading the appropriate JDBC driver, establishing a connection with the database using a connection URL, executing SQL statements using Statement objects to retrieve and process result sets, and closing the connection when done. The core steps are to load the driver, get a connection, create statements, execute queries/updates, process results, and close the connection.
This document discusses using JDBC to access databases from Java applications like JSP pages. It covers loading the appropriate JDBC driver, establishing a connection with the database using a connection URL, executing SQL statements using Statement objects to retrieve and process result sets, and closing the connection when done. The core steps are to load the driver, get a connection, create statements, execute queries/updates, process results, and close the connection.
This document provides an overview of using Java Database Connectivity (JDBC) to connect to and interact with relational databases from Java servlets. It describes relational databases and how they organize data into tables. It explains the basic JDBC connection flow of getting a connection, executing SQL statements, and reading results. It also covers key JDBC interfaces like Connection, Statement, and ResultSet. The document provides an example servlet for looking up phone numbers from a database and discusses best practices like reusing connections and using connection pooling.
This document provides an overview of Java Database Connectivity (JDBC) and how to use it. It discusses how JDBC works by registering drivers, connecting to databases, and executing SQL statements. It also provides steps for configuring JDBC with Eclipse and Microsoft SQL Server, including downloading drivers and copying files. Examples are given for creating tables, executing queries with the Statement interface, and fetching data from the ResultSet. The document concludes by demonstrating how to properly close resources.
This document discusses Java Database Connectivity (JDBC) and provides details on connecting to a database from a Java application. There are 4 types of JDBC drivers that enable connection. Connecting involves 5 steps - registering the driver class, creating a connection, creating a statement, executing queries, and closing the connection. Examples are provided for connecting to MySQL and MS Access databases.
This document provides an overview of JDBC (Java Database Connectivity) and the different types of JDBC drivers. It discusses the four types of JDBC drivers: Type 1 (JDBC-ODBC bridge), Type 2 (JDBC-Native API), Type 3 (JDBC-Net pure Java), and Type 4 (100% pure Java). It describes the characteristics of each driver type and when each might be used. The document also covers basic JDBC concepts like establishing a database connection, executing statements, and retrieving result sets.
JDBC provides a standard interface for connecting to relational databases from Java applications. It establishes a connection by loading a JDBC driver, then executing SQL statements using objects like Statement and PreparedStatement. Results are retrieved into a ResultSet which can be processed row-by-row. Finally, connections are closed to release resources.
The document discusses using JDBC (Java Database Connectivity) for object-relational mapping in Java. It covers connecting to databases, executing SQL statements and queries, working with ResultSets, and best practices for managing database connections. Key points include using the DriverManager class to obtain database connections, preparing statements for parameterized queries, and implementing a DAO (Data Access Object) layer to encapsulate data access logic.
In this core java training session, you will learn JDBC Cont. Topics covered in this session are:
• JDBC Continued
• Introduction to Java Enterprise Edition (Java EE)
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
This document provides an overview of using JDBC (Java Database Connectivity) to access databases from Java applications. It covers the main JDBC concepts like drivers, connections, statements, result sets, and transactions. It also describes the typical steps for querying and updating databases using JDBC: establishing a connection, creating statements, executing SQL statements, processing result sets, and closing resources. The document includes examples for connecting to Oracle and ODBC databases and using prepared statements. It discusses best practices like using connection pools, tuning transactions, and optimizing SQL queries.
The document discusses several JDBC APIs used for connecting Java applications to databases. The Connection interface is used to create a connection to a database and execute SQL statements. The Statement interface executes static SQL queries and retrieves results. The PreparedStatement interface executes dynamic queries with IN parameters by using placeholder values set using methods like setInt() and setString(). Examples of using these interfaces will be provided in subsequent chapters.
This document provides an overview of Spring's transaction management capabilities. It discusses how Spring provides a uniform transaction management API that can work with various transaction technologies like JDBC, Hibernate, JPA etc. It also describes how transactions can be handled programmatically using the TransactionTemplate or directly through the transaction manager. Finally, it covers Spring's declarative transaction support using XML or annotations.
HijackLoader Evolution: Interactive Process HollowingDonato Onofri
CrowdStrike researchers have identified a HijackLoader (aka IDAT Loader) sample that employs sophisticated evasion techniques to enhance the complexity of the threat. HijackLoader, an increasingly popular tool among adversaries for deploying additional payloads and tooling, continues to evolve as its developers experiment and enhance its capabilities.
In their analysis of a recent HijackLoader sample, CrowdStrike researchers discovered new techniques designed to increase the defense evasion capabilities of the loader. The malware developer used a standard process hollowing technique coupled with an additional trigger that was activated by the parent process writing to a pipe. This new approach, called "Interactive Process Hollowing", has the potential to make defense evasion stealthier.
Discover the benefits of outsourcing SEO to Indiadavidjhones387
"Discover the benefits of outsourcing SEO to India! From cost-effective services and expert professionals to round-the-clock work advantages, learn how your business can achieve digital success with Indian SEO solutions.
Ready to Unlock the Power of Blockchain!Toptal Tech
Imagine a world where data flows freely, yet remains secure. A world where trust is built into the fabric of every transaction. This is the promise of blockchain, a revolutionary technology poised to reshape our digital landscape.
Toptal Tech is at the forefront of this innovation, connecting you with the brightest minds in blockchain development. Together, we can unlock the potential of this transformative technology, building a future of transparency, security, and endless possibilities.
2. 2
What is JDBC?
“An API that lets you access virtually any tabular data
source from the Java programming language”
JDBC Data Access API – JDBC Technology Homepage
What’s an API?
See J2SE documentation
What’s a tabular data source?
“… access virtually any data source, from relational
databases to spreadsheets and flat files.”
JDBC Documentation
We’ll focus on accessing Oracle databases
3. 3
General Architecture
What design pattern is
implied in this
architecture?
What does it buy for us?
Why is this architecture
also multi-tiered?
5. 5
Basic steps to use
a database in Java
1.Establish a connection
2.Create JDBC Statements
3.Execute SQL Statements
4.GET ResultSet
5.Close connections
6. 6
1. Establish a connection
import java.sql.*;
Load the vendor specific driver
Class.forName("oracle.jdbc.driver.OracleDriver");
What do you think this statement does, and how?
Dynamically loads a driver class, for Oracle database
Make the connection
Connection con = DriverManager.getConnection(
"jdbc:oracle:thin:@oracle-prod:1521:OPROD", username,
passwd);
What do you think this statement does?
Establishes connection to database by obtaining
a Connection object
7. 7
2. Create JDBC statement(s)
Statement stmt = con.createStatement() ;
Creates a Statement object for sending SQL statements
to the database
8. 8
Executing SQL Statements
String createLehigh = "Create table Lehigh " +
"(SSN Integer not null, Name VARCHAR(32), "
+ "Marks Integer)";
stmt.executeUpdate(createLehigh);
//What does this statement do?
String insertLehigh = "Insert into Lehigh values“
+ "(123456789,abc,100)";
stmt.executeUpdate(insertLehigh);
9. 9
Get ResultSet
String queryLehigh = "select * from Lehigh";
ResultSet rs = Stmt.executeQuery(queryLehigh);
//What does this statement do?
while (rs.next()) {
int ssn = rs.getInt("SSN");
String name = rs.getString("NAME");
int marks = rs.getInt("MARKS");
}
11. 11
Transactions and JDBC
JDBC allows SQL statements to be grouped together into a
single transaction
Transaction control is performed by the Connection object,
default mode is auto-commit, I.e., each sql statement is treated
as a transaction
We can turn off the auto-commit mode with
con.setAutoCommit(false);
And turn it back on with con.setAutoCommit(true);
Once auto-commit is off, no SQL statement will be committed
until an explicit is invoked con.commit();
At this point all changes done by the SQL statements will be
made permanent in the database.
12. 12
Handling Errors with
Exceptions
Programs should recover and leave the database in
a consistent state.
If a statement in the try block throws an exception or
warning, it can be caught in one of the
corresponding catch statements
How might a finally {…} block be helpful here?
E.g., you could rollback your transaction in a
catch { …} block or close database connection and
free database related resources in finally {…} block
13. 13
Another way to access database
(JDBC-ODBC)
What’s a bit different
about this
architecture?
Why add yet
another layer?
14. 14
Sample program
import java.sql.*;
class Test {
public static void main(String[] args) {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //dynamic loading of driver
String filename = "c:/db1.mdb"; //Location of an Access database
String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=";
database+= filename.trim() + ";DriverID=22;READONLY=true}"; //add on to end
Connection con = DriverManager.getConnection( database ,"","");
Statement s = con.createStatement();
s.execute("create table TEST12345 ( firstcolumn integer )");
s.execute("insert into TEST12345 values(1)");
s.execute("select firstcolumn from TEST12345");
15. 15
Sample program(cont)
ResultSet rs = s.getResultSet();
if (rs != null) // if rs == null, then there is no ResultSet to view
while ( rs.next() ) // this will step through our data row-by-row
{ /* the next line will get the first column in our current row's ResultSet
as a String ( getString( columnNumber) ) and output it to the screen */
System.out.println("Data from column_name: " + rs.getString(1) );
}
s.close(); // close Statement to let the database know we're done with it
con.close(); //close connection
}
catch (Exception err) { System.out.println("ERROR: " + err); }
}
}
17. 17
JDBC 2 – Scrollable Result Set
…
Statement stmt =
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
String query = “select students from class where type=‘not sleeping’ “;
ResultSet rs = stmt.executeQuery( query );
rs.previous(); / / go back in the RS (not possible in JDBC 1…)
rs.relative(-5); / / go 5 records back
rs.relative(7); / / go 7 records forward
rs.absolute(100); / / go to 100th record
…
18. 18
JDBC 2 – Updateable ResultSet
…
Statement stmt =
con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
String query = " select students, grade from class
where type=‘really listening this presentation’ “;
ResultSet rs = stmt.executeQuery( query );
…
while ( rs.next() )
{
int grade = rs.getInt(“grade”);
rs.updateInt(“grade”, grade+10);
rs.updateRow();
}
19. 19
Metadata from DB
A Connection's database is able
to provide schema information
describing its tables,
its supported SQL grammar,
its stored procedures
the capabilities of this connection, and so on
What is a stored procedure?
Group of SQL statements that form a logical unit
and perform a particular task
This information is made available through
a DatabaseMetaData object.
21. 21
JDBC – Metadata from RS
public static void printRS(ResultSet rs) throws SQLException
{
ResultSetMetaData md = rs.getMetaData();
// get number of columns
int nCols = md.getColumnCount();
// print column names
for(int i=1; i < nCols; ++i)
System.out.print( md.getColumnName( i)+",");
/ / output resultset
while ( rs.next() )
{ for(int i=1; i < nCols; ++i)
System.out.print( rs.getString( i)+",");
System.out.println( rs.getString(nCols) );
}
}
22. 22
JDBC and beyond
(JNDI) Java Naming and Directory Interface
API for network-wide sharing of information about users,
machines, networks, services, and applications
Preserves Java’s object model
(JDO) Java Data Object
Models persistence of objects, using RDBMS as repository
Save, load objects from RDBMS
(SQLJ) Embedded SQL in Java
Standardized and optimized by Sybase, Oracle and IBM
Java extended with directives: # sql
SQL routines can invoke Java methods
Maps SQL types to Java classes
23. 24
JDBC references
JDBC Data Access API – JDBC Technology Homepage
http://java.sun.com/products/jdbc/index.html
JDBC Database Access – The Java Tutorial
http://java.sun.com/docs/books/tutorial/jdbc/index.html
JDBC Documentation
http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/index.html
java.sql package
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/package-summary.html
JDBC Technology Guide: Getting Started
http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/GettingStartedTOC.fm.html
JDBC API Tutorial and Reference (book)
http://java.sun.com/docs/books/jdbc/
24. 25
JDBC
JDBC Data Access API – JDBC Technology Homepage
http://java.sun.com/products/jdbc/index.html
JDBC Database Access – The Java Tutorial
http://java.sun.com/docs/books/tutorial/jdbc/index.html
JDBC Documentation
http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/index.html
java.sql package
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/package-summary.html
JDBC Technology Guide: Getting Started
http://java.sun.com/j2se/1.4.2/docs/guide/jdbc/getstart/GettingStartedTOC.fm.html
JDBC API Tutorial and Reference (book)
http://java.sun.com/docs/books/jdbc/