JDBC Java Database Connectivity is a Java feature that lets you connect

Size: px
Start display at page:

Download "JDBC Java Database Connectivity is a Java feature that lets you connect"

Transcription

1 Chapter 4: Using JDBC to Connect to a Database In This Chapter Configuring JDBC drivers Creating a connection Executing SQL statements Retrieving result data Updating and deleting data JDBC Java Database Connectivity is a Java feature that lets you connect to almost any relational database system, execute SQL commands, and process the results all from within a Java program. In this chapter, you set up JDBC and use it to access data in a MySQL database. If you aren t familiar with the basics of SQL, read the previous chapter before you tackle this chapter. Setting Up a Driver Before you can write a Java program to access a database via JDBC, you must first install a driver that links Java s database API classes to an actual database. Getting the driver set up right can be tricky, but once you get it working, accessing the database is easy. The following sections describe two basic approaches to setting up a driver to connect to a database: ODBC or a database connector. Setting up an ODBC data source ODBC is a generic database connection standard that almost every database program available can speak to. It s inherently inefficient, but it is easy to set up and performs adequately for small applications and for testing purposes. If you re using Access files for your database, ODBC is the way to go. Assuming you have created a database in Access that you want to access from a Java program, you can follow these steps to create an ODBC data source for the Access database:

2 718 Setting Up a Driver 1. Open the Control Panel and double-click Administrative Tools. A window with icons for various administrative tools comes up. 2. Double click Data Sources (ODBC). The ODBC Data Source Administrator dialog box opens, as shown in Figure 4-1. Figure 4-1: The ODBC Data Source Administrator dialog box. 3. Click the System DSN tab, and then click Add. A dialog box listing a bunch of ODBC drivers appears. 4. Choose Microsoft Access Driver, and then click Finish. The Finish button is strangely named, but this is when the real configuration actually begins. The dialog box shown in Figure 4-2 now appears. Figure 4-2: Configuring an Access data source.

3 Using JDBC to Connect to a Database Setting Up a Driver Type a name for the data source. You use this name in your Java program to access the data source, so choose it wisely. 6. Click the Select button, and then choose the database you want to connect to and click OK. A Select Database dialog box appears. From this dialog box, you can navigate to the folder that contains your Access data file to select it. 7. Click OK. The data source is added to the list of configured ODBC data sources. 8. Click OK to dismiss the ODBC Data Source Administrator. You re all done. Setting up the MySQL JDBC connector An alternative to using ODBC is to use a database connector, which is a driver provided by your database vendor. Database connectors are designed to work exclusively with a specific type of database. As a result, they re considerably more efficient and powerful than ODCB. You have to obtain the JDBC connector for the database you re using from the company that makes the database server you re using. For example, you can get a JDBC connector for MySQL from the MySQL Web site at com. Along with the driver, you get detailed instructions on how to set it up. But the following procedure works for a simple testing environment: 1. Download the driver from and unzip it. The driver you re looking for is called MySQL Connector/J. After you download it from MySQL s Web site, unzip the files to any folder you wish. I suggest one with a simple pathname, such as c:\mysql. 2. Add the driver s.jar file to your ClassPath variable. To change the ClassPath, open Control Panel and double-click System. Then, click the Advanced tab, and then click Environment Variables. You can then click New to add a new environment variable. The ClassPath variable has to specify the complete path for the connector s jar file. For example, here s a sample ClassPath variable for a driver located in c:\mysql:.;c:\mysql\mysql-connector-java bin.jar Notice that the ClassPath variable starts with a period and a semicolon. This ensures that Java can find classes that are in the current directory. Book VIII Chapter 4

4 720 Connecting to a Database If the ClassPath variable already exists, just add the connector s jar file to the end of the existing text. That s all you have to do. You can now connect to MySQL from a Java program. Connecting to a Database Before you can use JDBC to access a SQL database, you must first establish a connection to the database. The first step to establishing a connection involves registering the driver class so the class is available. To do that, you use the forname method of the Class class, specifying the package and class name of the driver. For example, to register the MySQL connector, use this statement: Class.forName( com.mysql.jdbc.driver ); To register the standard ODBC driver, use this statement instead: Class.forName( sun.jdbc.odbc.jdbcodbcdriver ); Note that the forname method throws ClassNotFoundException, so you have to enclose this statement in a /catch block that catches ClassNotFoundException. After you register the driver class, you can call the static getconnection method of the DriverManager class to open the connection. This method takes three String parameters: the database URL, the user name, and a password. Here s an example: String url = jdbc:mysql://localhost/movies ; String user = root ; String pw = pw ; con = DriverManager.getConnection(url, user, pw); The URL parameter has the following syntax: jdbc:subprotocol:subname where subprotocol is mysql for a MySQL database and odbc for an ODBC driver. The subname is the database name. For a MySQL database, this can be a complete URL, but for a database on your own computer, you just specify //localhost/ plus the name of the database. For ODBC, you use the name you used when you created the data source. For example String url = jdbc:odbc:movies ;

5 Using JDBC to Connect to a Database Querying a Database 721 The user and password parameters must also be valid for the database server you re using. For testing purposes on a MySQL database, you can use root and the password you created when you installed MySQL. For ODBC, use admin with no password for testing. Note that the getconnection method throws SQLException, so you need to enclose it in a /catch block statement that catches this exception. Putting it all together, here s a method that returns a Connection object that connects to the movies database in MySQL: private static Connection getconnection() Connection con = null; Class.forName( com.mysql.jdbc.driver ); String url = jdbc:mysql://localhost/movies ; String user = root ; String pw = NuttMutt ; con = DriverManager.getConnection(url, user, pw); catch (ClassNotFoundException e) System.exit(0); System.exit(0); return con; You can find these classes and the other classes for working with SQL databases in the java.sql package. As a result, you have to include an import statement that specifies this package in any program that uses JDBC. Book VIII Chapter 4 Querying a Database After you establish a connection to a database, you can execute select statements to retrieve data. To do so, you have to use several classes and interfaces: Connection: The Connection class has two methods you re likely to use. The close method closes the connection, and the createstatement method returns a Statement object, which you then use to execute statements.

6 722 Querying a Database Statement: The Statement interface contains the methods necessary to send statements to the database for execution and return the results. In particular, you use the executequery method to execute a select statement or the executeupdate method to execute an insert, update, or delete statement. ResultSet: The ResultSet interface represents rows returned from a query. It provides methods you can use to move from row to row and to get the data for a column. Table 4-1 lists the methods of the Connection class and the Statement interface you use to execute queries. You find out about the many methods of the ResultSet interface later in this chapter, in the section Navigating through the result set. Table 4-1 Connection Class Methods void close() Statement createstatement() Statement createstatement (int type, int concur) Statement Interface Methods ResultSet executequery (String sql) ResultSet executequery (String sql) int executeupdate (String sql) Connection and Statement Methods Description Closes the connection. Creates a Statement object that can execute a SQL statement on the database connected by the connection. Creates a Statement object that can execute a SQL statement on the database connected by the connection. Description Executes the select statement contained in the string parameter and returns the result data as a ResultSet object. Executes the select statement contained in the string parameter and returns the result data as a ResultSet object. Executes the insert, update, or delete statements contained in the string parameter and returns the result data as a ResultSet object. The first parameter of the createstatement method specifies the type of result set that is created, and can be one of the following: ResultSet.TYPE_FORWARD_ONLY ResultSet.TYPE_SCROLL_INSENSITIVE ResultSet.TYPE_SCROLL_SENSITIVE The second parameter indicates whether the result set is read-only or updatable, and can be one of the following:

7 Using JDBC to Connect to a Database Querying a Database 723 ResultSet.CONCUR_READ_ONLY ResultSet.CONSUR_UPDATABLE Executing a select statement The following snippet executes a select statement and gets the result set: Statement s = con.createstatement(); String select = Select title, year, price + from movie order by year ; ResultSet rows = s.executequery(select); Here, the result set is stored in the rows variable. Navigating through the result set The ResultSet object returned by the executequery statement contains all the rows that are retrieved by the select statement. You can only access one of those rows at a time. The result set maintains a pointer called a cursor to keep track of the current row. You can use the methods shown in Table 4-2 to move the cursor through a result set. For example, the following snippet shows how you can structure code that processes each row in a result set: while(rows.next()) // process the current row All you have to do is replace the comment with statements that retrieve data from the result set and process it, as described in the next section. Table 4-2 Method void close() void last() int getrow() boolean next() Navigation Methods of the ResultSet Interface Description Closes the result set. Moves the cursor to the last row. Gets the current row number. Moves to the next row. Book VIII Chapter 4 Getting data from a result set Table 4-3 lists the methods of the ResultSet interface you can use to retrieve data from the current row. As you can see, each of these methods comes in two versions: One specifies the column by name, the other by

8 724 Querying a Database index number. If you know the index number, using it to access the column values is more efficient than using the column names. Here s a bit of code that gets the title, year, and price for the current row: String title = row.getstring( title ); int year = row.getint( year ); double price = row.getdouble( price ); The following code does the same thing, assuming the columns appear in order: String title = row.getstring(1); int year = row.getint(2); double price = row.getdouble(3); Note that unlike almost every other index in Java, column indexes start with 1, not zero. Table 4-3 Method BigDecimal getbigdecimal(string columnname) BigDecimal getbigdecimal(int columnindex) boolean getboolean(string columnname) Get Methods of the ResultSet Interface Description column as a BigDecimal. column as a BigDecimal. column as a boolean. boolean getboolean(int columnindex) column as a boolean. Date getdate(string columnname) Date getdate(int columnindex) column as a Date. column as a Date. double getdouble(string columnname) column as a double. double getdouble(int columnindex) float getfloat(string columnname) float getfloat(int columnindex) int getint(string columnname) int getint(int columnindex) column as a double. column as a float. column as a float. column as a int. column as a int.

9 Using JDBC to Connect to a Database Querying a Database 725 Method long getlong(string columnname) long getlong(int columnindex) short getshort(string columnname) short getshort(int columnindex) Description column as a long. column as a long. column as a short. column as a short. String getstring(string columnname) column as a String. String getstring(int columnindex) column as a String. Putting it all together: A program that reads from a database Now that you ve seen the various elements that make up a program that uses JDBC to query a database, Listing 4-1 shows a program that reads data from the movies database and lists it on the console. When you run this program, the following appears on the console: 1946: It s a Wonderful Life ($16.45) 1965: The Great Race ($14.25) 1974: Young Frankenstein ($18.65) 1975: The Return of the Pink Panther ($13.15) 1977: Star Wars ($19.75) 1987: The Princess Bride ($18.65) 1989: Glory ($16.45) 1995: Apollo 13 ($20.85) 1997: The Game ($16.45) 2001: The Lord of the Rings: The Fellowship of the Ring ($21.95) Book VIII Chapter 4 LISTING 4-1: THE MOVIE LISTING PROGRAM import java.sql.*; import java.text.numberformat; public class ListMovies public static void main(string[] args) 6 NumberFormat cf = NumberFormat.getCurrencyInstance(); ResultSet movies = getmovies(); continued

10 726 Querying a Database LISTING 4-1 (CONTINUED) while (movies.next()) Movie m = getmovie(movies); String msg = Integer.toString(m.year); msg += : + m.title; msg += ( + cf.format(m.price) + ) ; System.out.println(msg); private static ResultSet getmovies() 28 Connection con = getconnection(); Statement s = con.createstatement(); String select = Select title, year, price + from movie order by year ; ResultSet rows; rows = s.executequery(select); return rows; return null; private static Connection getconnection() 46 Connection con = null; Class.forName( com.mysql.jdbc.driver ); String url = jdbc:mysql://localhost/movies ; String user = root ; String pw = NuttMutt ; con = DriverManager.getConnection(url, user, pw); catch (ClassNotFoundException e) System.exit(0);

11 Using JDBC to Connect to a Database Querying a Database 727 System.exit(0); return con; private static Movie getmovie(resultset movies) 70 String title = movies.getstring( Title ); int year = movies.getint( Year ); double price = movies.getdouble( Price ); return new Movie(title, year, price); return null; private static class Movie 86 public String title; public int year; public double price; public Movie(String title, int year, double price) this.title = title; this.year = year; this.price = price; The following paragraphs describe the basics of how this program works: 6 The main method begins by calling the getmovies method to get a ResultSet object that contains the movies to be listed. Then, a while loop reads each row of the result set. The getmovie method is called to create a Movie object from the data in the current row. Then, an output string is created and sent to the console. The loop is contained in a /catch statement because the next method may throw SQLException. 28 The getmovies method is responsible for getting a database connection, and then querying the database to get the movies. The first task is delegated to the getconnection method. Then, a Statement is created and executed with the following select statement: select title, year, price from movie order by year Then, the result set is returned to the main method. Book VIII Chapter 4

12 728 Updating SQL Data 46 The getconnection method creates a Connection object to the database. Note that the user id and password are hard-coded into this method. In a real application, you get this information from the user or from a configuration file. 70 The getmovie method extracts the title, year, and price from the current row and uses these values to create a Movie object. 86 The Movie class is created as an inner class. To keep this application simple, this class uses public fields and a single constructor that initializes the fields with the values passed as parameters. Updating SQL Data Besides executing select statements, you can also use a Statement object to execute insert, update, or delete statements as well. To do that, you call the executeupdate method instead of the executequery method. This method returns an int value that indicates how many rows were updated. You can test the return value to determine whether the data was properly updated. For example, here s a method that accepts a movie id, last name, and first name and inserts a row into the friend table: private static void loanmovie(int id, String lastname, String firstname) Connection con = getconnection(); Statement stmt = con.createstatement(); String insert = insert into friend + (lastname, firstname, movieid) + values ( + \ + lastname + \, \ + firstname + \, + + id + ) ; int i = stmt.executeupdate(insert); if (i == 1) System.out.println( Loan recorded. ); else System.out.println( Loan not recorded. ); System.exit(0);

13 Using JDBC to Connect to a Database Using an Updatable RowSet Object 729 The getconnection method called at the start of this method is the same getconnection method in Listing 4-1. After a connection is created, a Statement object is created, and an insert statement is constructed using the values passed via the parameters. For example, if you pass id 3, last name Haskell, and first name Eddie, the following insert statement is built: Insert into friend (lastname, firstname, movieid) Values ( Haskell, Eddie, 3) Then, the executeupdate method is called to execute the insert statement. An if statement is used to determine whether or not the row is inserted. You can execute update or delete statements in the same manner. While you re testing database code that executes SQL statements constructed from strings like this, throw in a System.out.println call to print the statement to the console. That way, you can verify that the statement is being created properly. Using an Updatable RowSet Object If you re using a newer JDBC driver (one that supports JDBC 2.0 or later), you have another option for updating data: with an updatable result set. With an updatable result set, you can change data in a result set row, add a row to the result set, or delete a row from the result set. When you do, the updates are automatically written back to the underlying database. To create an updatable result set, you must specify the ResultSet. CONCUR_UPDATABLE field on the createstatement method when you create the Statement object, like this: Statement stmt = con.createstatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.TYPE_CONCUR_UPDATABLE); The first parameter indicates that the result set is scrollable, which means you can move the cursor backwards as well as forwards through the result set. You can use the methods listed in Table 4-4 to scroll the result set. This parameter also indicates that the result set can be synchronized with the database so that any changes made by other users are reflected in the result set. Book VIII Chapter 4

14 730 Using an Updatable RowSet Object Table 4-4 Method boolean absolute (int row) void afterlast() Methods for Scrollable Result Sets Description Moves the cursor to the given row number in this ResultSet object. Moves the cursor to the end of this ResultSet object, just after the last row. void beforefirst()moves the cursor to the front of this ResultSet object, just before the first row. boolean first() boolean last() boolean next() Moves the cursor to the first row in this ResultSet object. Moves the cursor to the last row in this ResultSet object. Moves the cursor down one row from its current position. boolean previous()moves the cursor to the previous row in this ResultSet object. boolean relative (int rows) Moves the cursor a relative number of rows, either positive or negative. The second parameter indicates that the result set is updatable, and any changes you make to the result set are automatically written back to the database. You can use any of the methods listed in Table 4-5 to update the result set, and thus update the underlying database. Table 4-5 Method Methods for Updatable Result Sets Description void cancelrowupdates() Cancels the updates made to the current row in this ResultSet object. void deleterow() void insertrow() Deletes the current row from this ResultSet object and from the underlying database. Inserts the contents of the insert row into this ResultSet object and into the database. void movetocurrentrow() Moves the cursor to the remembered cursor position, usually the current row. void movetoinsertrow() void refreshrow() void updaterow() Moves the cursor to the insert row. Refreshes the current row with its most recent value in the database. Updates the underlying database with the new contents of the current row of this ResultSet object. Deleting a row To delete a row from a result set, use one of the navigation methods in Table 4-4 to move to the row you want to delete, and then use the deleterow

15 Using JDBC to Connect to a Database Using an Updatable RowSet Object 731 method to delete the row. For example, here s code that deletes the third row in the result set: rs.absolute(3); rs.deleterow(); System.exit(0); Updating the value of a row column To update the value of a row column, navigate to the row you want to update, and then use one of the updater methods listed in Table 4-6 to change one or more column values. Finally, call updaterow to apply the changes. For example: rs.absolute(6); rs.updateint( year, 1975); rs.updaterow(); System.exit(0); Here, the year column of the sixth row in the result set is changed to Table 4-6 Update by Column Name void updatebigdecimal (String columnname, BigDecimal value) void updateboolean (String columnname, boolean value) Update Methods of the ResultSet Interface Update by Column Index void updatebigdecimal(int columnindex, BigDecimal value) void updateboolean(int columnindex, boolean value) void updatedate(string void updatedate(int columnindex, columnname, Date value) Date value) (continued) Book VIII Chapter 4

16 732 Using an Updatable RowSet Object Table 4-6 (continued) Update by Column Name void updatedouble (String columnname, double value) Update by Column Index void updatedouble(int columnindex, double value) void updatefloat(string void updatefloat(int columnindex, columnname, float value) float value) void updateint(string columnname, int value) void updatelong(string columnname, long value) void updateint(int columnindex, int value) void updatelong(int columnindex, long value) void updateshort(string void updateshort(int columnindex, columnname, short value) short value) void updatestring(string void updatestring(int columnname, String columnindex, String value) value) Inserting a row To insert a row, you use a special row in the result set called the insert row. First, you call the movetoinsertrow method to move the cursor to the insert row. Then, you use update methods to set the value for each column in the insert row. You then call the insertrow method to copy the insert row into the result set, which in turn writes a new row to the database. And finally, you call movetocurrentrow to move back to the previous position in the result set. Here s an example: rs.movetoinsertrow(); rs.updatestring( title, Monty Python and the Holy Grail ); rs.updateint( year, 1975); rs.updatedouble( price, 13.95); rs.insertrow(); rs.movetocurrentrow(); System.exit(0);

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text

e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text e-pg Pathshala Subject: Computer Science Paper: Web Technology Module: JDBC INTRODUCTION Module No: CS/WT/26 Quadrant 2 e-text Learning Objectives This module gives an introduction about Java Database

More information

JDBC 3.0. Java Database Connectivity. 1 Java

JDBC 3.0. Java Database Connectivity. 1 Java JDBC 3.0 Database Connectivity 1 Contents 1 JDBC API 2 JDBC Architecture 3 Steps to code 4 Code 5 How to configure the DSN for ODBC Driver for MS-Access 6 Driver Types 7 JDBC-ODBC Bridge 8 Disadvantages

More information

UNIT III - JDBC Two Marks

UNIT III - JDBC Two Marks UNIT III - JDBC Two Marks 1.What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for databaseindependent connectivity between the Java programming language and a wide

More information

Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview

Database Programming Overview. COSC 304 Introduction to Database Systems. Database Programming. JDBC Interfaces. JDBC Overview COSC 304 Introduction to Database Systems Database Programming Dr. Ramon Lawrence University of British Columbia Okanagan ramon.lawrence@ubc.ca Database Programming Overview Most user interaction with

More information

SNS COLLEGE OF ENGINEERING, Coimbatore

SNS COLLEGE OF ENGINEERING, Coimbatore SNS COLLEGE OF ENGINEERING, Coimbatore 641 107 Accredited by NAAC UGC with A Grade Approved by AICTE and Affiliated to Anna University, Chennai IT6503 WEB PROGRAMMING UNIT 03 JDBC JDBC Overview JDBC implementation

More information

SQL stands for Structured Query Language. SQL is the lingua franca

SQL stands for Structured Query Language. SQL is the lingua franca Chapter 3: Database for $100, Please In This Chapter Understanding some basic database concepts Taking a quick look at SQL Creating tables Selecting data Joining data Updating and deleting data SQL stands

More information

Top 50 JDBC Interview Questions and Answers

Top 50 JDBC Interview Questions and Answers Top 50 JDBC Interview Questions and Answers 1) What is the JDBC? JDBC stands for Java Database Connectivity. JDBC is a Java API that communicates with the database and execute SQLquery. 2) What is a JDBC

More information

This lecture. Databases - JDBC I. Application Programs. Database Access End Users

This lecture. Databases - JDBC I. Application Programs. Database Access End Users This lecture Databases - I The lecture starts discussion of how a Java-based application program connects to a database using. (GF Royle 2006-8, N Spadaccini 2008) Databases - I 1 / 24 (GF Royle 2006-8,

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity ADVANCED FEATURES Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Scrollable

More information

Working with Databases and Java

Working with Databases and Java Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured

More information

JAVA AND DATABASES. Summer 2018

JAVA AND DATABASES. Summer 2018 JAVA AND DATABASES Summer 2018 JDBC JDBC (Java Database Connectivity) an API for working with databases in Java (works with any tabular data, but focuses on relational databases) Works with 3 basic actions:

More information

JDBC - INTERVIEW QUESTIONS

JDBC - INTERVIEW QUESTIONS JDBC - INTERVIEW QUESTIONS http://www.tutorialspoint.com/jdbc/jdbc_interview_questions.htm Copyright tutorialspoint.com Dear readers, these JDBC Interview Questions have been designed specially to get

More information

Chapter 16: Databases

Chapter 16: Databases Chapter 16: Databases Starting Out with Java: From Control Structures through Objects Fifth Edition by Tony Gaddis Chapter Topics Chapter 16 discusses the following main topics: Introduction to Database

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity Introduction Java Database Connectivity (JDBC) provides a standard library for accessing databases. The JDBC API contains number of interfaces and classes that are extensively

More information

DB I. 1 Dr. Ahmed ElShafee, Java course

DB I. 1 Dr. Ahmed ElShafee, Java course Lecture (15) DB I Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, Java course Agenda 2 Dr. Ahmed ElShafee, Java course Introduction Java uses something called JDBC (Java Database Connectivity) to connect to databases.

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

Databases 2012 Embedded SQL

Databases 2012 Embedded SQL Databases 2012 Christian S. Jensen Computer Science, Aarhus University SQL is rarely written as ad-hoc queries using the generic SQL interface The typical scenario: client server database SQL is embedded

More information

UNIT-3 Java Database Client/Server

UNIT-3 Java Database Client/Server UNIT-3 Java Database Client/Server TOPICS TO BE COVERED 3.1 Client-Server Design: Two-Tier Database Design, Three-Tier Database Design 3.2 The JDBC API: The API Components, Database Creation, table creation

More information

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry

DataBase Lab JAVA-DATABASE CONNECTION. Eng. Haneen El-masry In the name of Allah Islamic University of Gaza Faculty of Engineering Computer Engineering Department ECOM 4113 DataBase Lab Lab # 9 JAVA-DATABASE CONNECTION El-masry 2013 Objective In this lab, we turn

More information

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim

ERwin and JDBC. Mar. 6, 2007 Myoung Ho Kim ERwin and JDBC Mar. 6, 2007 Myoung Ho Kim ERwin ERwin a popular commercial ER modeling tool» other tools: Dia (open source), Visio, ConceptDraw, etc. supports database schema generation 2 ERwin UI 3 Data

More information

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 -

CMPUT 391 Database Management Systems. JDBC in Review. - Lab 2 - CMPUT 391 Database Management Systems JDBC in Review - - Department of Computing Science University of Alberta What Is JDBC? JDBC is a programming interface JDBC allows developers using java to gain access

More information

Accessing databases in Java using JDBC

Accessing databases in Java using JDBC Accessing databases in Java using JDBC Introduction JDBC is an API for Java that allows working with relational databases. JDBC offers the possibility to use SQL statements for DDL and DML statements.

More information

13 Creation and Manipulation of Tables and Databases

13 Creation and Manipulation of Tables and Databases 150.420 Informationslogistik SQL Handout No. 9 SS 2013 13 Creation and Manipulation of Tables and Databases 13.1 Creation and Deletion Databases can be created and deleted using respectively. CREATE DATABASE

More information

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley

CSCI/CMPE Object-Oriented Programming in Java JDBC. Dongchul Kim. Department of Computer Science University of Texas Rio Grande Valley CSCI/CMPE 3326 Object-Oriented Programming in Java JDBC Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Introduction to Database Management Systems Storing data in traditional

More information

O ne of the most important features of JavaServer

O ne of the most important features of JavaServer INTRODUCTION TO DATABASES O ne of the most important features of JavaServer Pages technology is the ability to connect to a Databases store and efficiently manage large collections of information. JSP

More information

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection.

JDBC Architecture. JDBC API: This provides the application-to- JDBC Manager connection. JDBC PROGRAMMING JDBC JDBC Java DataBase Connectivity Useful for database driven applications Standard API for accessing relational databases Compatible with wide range of databases Current Version JDBC

More information

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi

Cyrus Shahabi Computer Science Department University of Southern California C. Shahabi Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

Application Programming for Relational Databases

Application Programming for Relational Databases Application Programming for Relational Databases Cyrus Shahabi Computer Science Department University of Southern California shahabi@usc.edu 1 Overview JDBC Package Connecting to databases with JDBC Executing

More information

JDBC BASIC 19/05/2012. Objectives. Java Database Connectivity. Definitions of JDBC. Part 1. JDBC basic Working with JDBC Adv anced JDBC programming

JDBC BASIC 19/05/2012. Objectives. Java Database Connectivity. Definitions of JDBC. Part 1. JDBC basic Working with JDBC Adv anced JDBC programming Objectives Java Database Connectivity JDBC basic Working with JDBC Adv anced JDBC programming By Võ Văn Hải Faculty of Information Technologies Summer 2012 2/27 Definitions of JDBC JDBC APIs, which provides

More information

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem

Allenhouse Institute of Technology (UPTU Code : 505) OOT Notes By Hammad Lari for B.Tech CSE V th Sem ECS-503 Object Oriented Techniques UNIT-5 Course Jdbc... 1 Servlets... 17 JDBC --> The database is the heart of any enterpries system which is used to store and retrieve the data of enterprise more efficiently.

More information

Java Database Connectivity (JDBC) 25.1 What is JDBC?

Java Database Connectivity (JDBC) 25.1 What is JDBC? PART 25 Java Database Connectivity (JDBC) 25.1 What is JDBC? JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming

More information

SQL and Java. Database Systems Lecture 20 Natasha Alechina

SQL and Java. Database Systems Lecture 20 Natasha Alechina Database Systems Lecture 20 Natasha Alechina In this Lecture SQL in Java SQL from within other Languages SQL, Java, and JDBC For More Information Sun Java tutorial: http://java.sun.com/docs/books/tutorial/jdbc

More information

MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065)

MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065) MANTHLY TEST SEPTEMBER 2017 QUESTION BANK CLASS: XII SUBJECT: INFORMATICS PRACTICES (065) DATABASE CONNECTIVITY TO MYSQL Level- I Questions 1. What is the importance of java.sql.*; in java jdbc connection?

More information

SQL in a Server Environment

SQL in a Server Environment SQL in a Server Environment Vaidė Narváez Computer Information Systems January 13th, 2011 The Three-Tier Architecture Application logic components Copyright c 2009 Pearson Education, Inc. Publishing as

More information

Lab # 9. Java to Database Connection

Lab # 9. Java to Database Connection Islamic University of Gaza Faculty of Engineering Department of Computer Engineering ECOM 4113: Lab # 9 Java to Database Connection Eng. Haneen El-Masry December, 2014 2 Objective In this lab, we turn

More information

Java Database Connectivity

Java Database Connectivity Java Database Connectivity INTRODUCTION Dr. Syed Imtiyaz Hassan Assistant Professor, Deptt. of CSE, Jamia Hamdard (Deemed to be University), New Delhi, India. s.imtiyaz@jamiahamdard.ac.in Agenda Introduction

More information

JDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases.

JDBC. Sun Microsystems has included JDBC API as a part of J2SDK to develop Java applications that can communicate with databases. JDBC The JDBC TM API is the application programming interface that provides universal data access for the Java TM platform. In other words, the JDBC API is used to work with a relational database or other

More information

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets

The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Course Name: Advanced Java Lecture 13 Topics to be covered The Design of JDBC The Structured Query Language Basic JDBC Programming Concepts Query Execution Scrollable and Updatable Result Sets Introducing

More information

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 1 SQL code in other programming languages SQL commands can be called from within a host language (e.g., C++ or Java) program.

More information

SQream Connector Native Python SQream Technologies Version 2.1.2

SQream Connector Native Python SQream Technologies Version 2.1.2 SQream Connector Native Python 2.1.2 SQream Technologies 2019-03-27 Version 2.1.2 Table of Contents The SQream Native Python Connector - Overview.............................................. 1 1. API

More information

COMP102: Introduction to Databases, 23

COMP102: Introduction to Databases, 23 COMP102: Introduction to Databases, 23 Dr Muhammad Sulaiman Khan Department of Computer Science University of Liverpool U.K. 04 April, 2011 Programming with SQL Specific topics for today: Client/Server

More information

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017

Part I: Stored Procedures. Introduction to SQL Programming Techniques. CSC 375, Fall 2017 Introduction to SQL Programming Techniques CSC 375, Fall 2017 The Six Phases of a Project: Enthusiasm Disillusionment Panic Search for the Guilty Punishment of the Innocent Praise for non-participants

More information

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity

Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Objectives Discuss setting up JDBC connectivity. Demonstrate a JDBC program Discuss and demonstrate methods associated with JDBC connectivity Setting Up JDBC Before you can begin to utilize JDBC, you must

More information

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree

BUSINESS INTELLIGENCE LABORATORY. Data Access: Relational Data Bases. Business Informatics Degree BUSINESS INTELLIGENCE LABORATORY Data Access: Relational Data Bases Business Informatics Degree RDBMS data access 2 Protocols and API ODBC, OLE DB, ADO, ADO.NET, JDBC JDBC Programming Java classes java.sql

More information

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import

Introduction to JDBC. JDBC: Java Database Connectivity. Why Access a Database with Java? Compilation. Six Steps. Packages to Import Introduction to JDBC JDBC: Java Database Connectivity JDBC is used for accessing databases from Java applications Information is transferred from relations to objects and vice-versa databases optimized

More information

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal

Enterprise Java Unit 1- Chapter 6 Prof. Sujata Rizal Introduction JDBC is a Java standard that provides the interface for connecting from Java to relational databases. The JDBC standard is defined by Sun Microsystems and implemented through the standard

More information

Java application using JDBC to connect to a database.

Java application using JDBC to connect to a database. JDBC(JAVA DATABASE CONNECTIVITY) The Java JDBC API enables Java applications to connect to relational databases via a standard API, so your Java applications become independent (almost) of the database

More information

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation

Kyle Brown Knowledge Systems Corporation by Kyle Brown and Knowledge Systems Corporation Kyle Brown Knowledge Systems Corporation 1 What is the JDBC? What other persistence mechanisms are available? What facilities does it offer? How is it used? 2 JDBC is the Java DataBase Connectivity specification

More information

Databases and SQL Lab EECS 448

Databases and SQL Lab EECS 448 Databases and SQL Lab EECS 448 Databases A database is an organized collection of data. Data facts are stored as fields. A set of fields that make up an entry in a table is called a record. Server - Database

More information

Unit 3 - Java Data Base Connectivity

Unit 3 - Java Data Base Connectivity Two-Tier Database Design The two-tier is based on Client-Server architecture. The direct communication takes place between client and server. There is no mediator between client and server. Because of

More information

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers.

Questions and Answers. A. A DataSource is the basic service for managing a set of JDBC drivers. Q.1) What is, in terms of JDBC, a DataSource? A. A DataSource is the basic service for managing a set of JDBC drivers B. A DataSource is the Java representation of a physical data source C. A DataSource

More information

Pieter van den Hombergh. March 25, 2018

Pieter van den Hombergh. March 25, 2018 ergh Fontys Hogeschool voor Techniek en Logistiek March 25, 2018 ergh/fhtenl March 25, 2018 1/25 JDBC JDBC is a Java database connectivity technology (Java Standard Edition platform) from Oracle Corporation.

More information

Database connectivity (II)

Database connectivity (II) Lecture (07) Database connectivity (II) Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems Agenda Connecting DB 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The

More information

Student Number: Please fill out the identification section above as well as the one on the back page, and read the instructions below. Good Luck!

Student Number: Please fill out the identification section above as well as the one on the back page, and read the instructions below. Good Luck! CSC 343H1S 2013 Test 2 Duration 50 minutes Aids allowed: none Last Name: Lecture Section: Day Student Number: First Name: Instructor: Horton Please fill out the identification section above as well as

More information

PERSİSTENCE OBJECT RELATİON MAPPİNG

PERSİSTENCE OBJECT RELATİON MAPPİNG PERSİSTENCE Most of the applications require storing and retrieving objects in a persistent storage mechanism. This chapter introduces how to store and retrieve information in a persistent storage with

More information

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford

Database Programming. Week 9. *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford Database Programming Week 9 *Some of the slides in this lecture are created by Prof. Ian Horrocks from University of Oxford SQL in Real Programs We have seen only how SQL is used at the generic query interface

More information

Cập nhật ResultSet trong JDBC

Cập nhật ResultSet trong JDBC java_jdbc/index.jsp Cập nhật ResultSet trong JDBC Tương tự như khi quan sát dữ liệu trong ResultSet, bạn có thể sử dụng rất nhiều phương thức (có 2 phiên bản cho chỉ mục cột và tên cột) của ResultSet Interface

More information

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server.

JDBC Drivers Type. JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. JDBC Drivers Type 1 What is JDBC Driver? JDBC drivers implement the defined interfaces in the JDBC API for interacting with your database server. For example, using JDBC drivers enable you to open database

More information

Persistency Patterns. Repository and DAO

Persistency Patterns. Repository and DAO Persistency Patterns Repository and DAO 1 Repository pattern Basically, the Repository pattern just means putting a façade over your persistence system so that you can shield the rest of your application

More information

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Science and Engineering

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Science and Engineering INTERNAL ASSESSMENT TEST 2 Date : 28-09-15 Max Marks :50 Subject & Code : JAVA&J2EE(10IS753) Section: VII A&B Name of faculty : Mr.Sreenath M V Time : 11.30-1.00 PM Note: Answer any five questions 1) a)

More information

Unit 2 JDBC Programming

Unit 2 JDBC Programming Q1. What is JDBC? Explain the types of JDBC drivers? Ans. What is JDBC? JDBC is an API, which is used in java programming for interacting with database. JDBC (Java DataBase Connection) is the standard

More information

Programming in Java

Programming in Java 320341 Programming in Java Fall Semester 2014 Lecture 16: Introduction to Database Programming Instructor: Slides: Jürgen Schönwälder Bendick Mahleko Objectives This lecture introduces the following -

More information

Accessing a database from Java. Using JDBC

Accessing a database from Java. Using JDBC Accessing a database from Java Using JDBC We ve got a fuzzbox and we re gonna use it Now we know a little about databases and SQL. So how do we access a database from a Java application? There is an API

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer About the Tutorial JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC works with Java on a variety of platforms, such as Windows, Mac

More information

3) execute() Usage: when you cannot determine whether SQL is an update or query return true if row is returned, use getresultset() to get the

3) execute() Usage: when you cannot determine whether SQL is an update or query return true if row is returned, use getresultset() to get the Agenda Lecture (07) Database connectivity (II) Connecting DB Dr. Ahmed ElShafee 1 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems 2 Dr. Ahmed ElShafee, ACU Spring 2011, Distributed Systems The

More information

Servlet 5.1 JDBC 5.2 JDBC

Servlet 5.1 JDBC 5.2 JDBC 5 Servlet Java 5.1 JDBC JDBC Java DataBase Connectivity Java API JDBC Java Oracle, PostgreSQL, MySQL Java JDBC Servlet OpenOffice.org ver. 2.0 HSQLDB HSQLDB 100% Java HSQLDB SQL 5.2 JDBC Java 1. JDBC 2.

More information

You write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets

You write standard JDBC API application and plug in the appropriate JDBC driver for the database the you want to use. Java applet, app or servlets JDBC Stands for Java Database Connectivity, is an API specification that defines the following: 1. How to interact with database/data-source from Java applets, apps, servlets 2. How to use JDBC drivers

More information

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science

Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } JDBC ("Java Database Connectivity ) is a set

More information

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC

Topic 12: Database Programming using JDBC. Database & DBMS SQL JDBC Topic 12: Database Programming using JDBC Database & DBMS SQL JDBC Database A database is an integrated collection of logically related records or files consolidated into a common pool that provides data

More information

CS221 Lecture: Java Database Connectivity (JDBC)

CS221 Lecture: Java Database Connectivity (JDBC) CS221 Lecture: Java Database Connectivity (JDBC) Objectives: 1. To introduce using JDBC to access a SQL database revised 10/20/14 Materials: 1. Projectable of registration system architecture. 2. JDBC

More information

Introduction to Databases [p.3]

Introduction to Databases [p.3] Object Oriented Programming and Internet Application Development Unit 5 The Back-end in Internet Software Introduction to Databases Relational Databases Designing a Relational Database Manipulating Data

More information

1. PhP Project. Create a new PhP Project as shown below and click next

1. PhP Project. Create a new PhP Project as shown below and click next 1. PhP Project Create a new PhP Project as shown below and click next 1 Choose Local Web Site (Apache 24 needs to be installed) Project URL is http://localhost/projectname Then, click next We do not use

More information

JDBC [Java DataBase Connectivity]

JDBC [Java DataBase Connectivity] JDBC [Java DataBase Connectivity] Introduction Almost all the web applications need to work with the data stored in the databases. JDBC is Java specification that allows the Java programs to access the

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Benjamin Köhncke Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Database APIs CLI ODBC JDBC Relational

More information

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014

Embedded SQL. csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Embedded SQL csc343, Introduction to Databases Diane Horton with examples from Ullman and Widom Fall 2014 Problems with using interactive SQL Standard SQL is not Turing-complete. E.g., Two profs are colleagues

More information

Tiers (or layers) Separation of concerns

Tiers (or layers) Separation of concerns Tiers (or layers) Separation of concerns Hiding the type of storage from the client class Let s say we have a program that needs to fetch objects from a storage. Should the program have to be concerned

More information

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA

COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA COP4540 TUTORIAL PROFESSOR: DR SHU-CHING CHEN TA: H S IN-YU HA OUTLINE Postgresql installation Introduction of JDBC Stored Procedure POSTGRES INSTALLATION (1) Extract the source file Start the configuration

More information

JDBC drivers are divided into four types or levels. The different types of jdbc drivers are:

JDBC drivers are divided into four types or levels. The different types of jdbc drivers are: How many types of JDBC Drivers are present and what are they? JDBC drivers are divided into four types or levels. The different types of jdbc drivers are: Type 1: JDBC-ODBC Bridge driver (Bridge) Type

More information

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL.

SQL: Programming. Announcements (September 25) Motivation. CPS 116 Introduction to Database Systems. Pros and cons of SQL. SQL: Programming CPS 116 Introduction to Database Systems Announcements (September 25) 2 Homework #2 due this Thursday Submit to Yi not through Jun s office door Solution available this weekend No class

More information

SQL DML and DB Applications, JDBC

SQL DML and DB Applications, JDBC SQL DML and DB Applications, JDBC Week 4.2 Week 4 MIE253-Consens 1 Schedule Week Date Lecture Topic 1 Jan 9 Introduction to Data Management 2 Jan 16 The Relational Model 3 Jan. 23 Constraints and SQL DDL

More information

Introduction to SQL & Database Application Development Using Java

Introduction to SQL & Database Application Development Using Java Introduction to SQL & Database Application Development Using Java By Alan Andrea The purpose of this paper is to give an introduction to relational database design and sql with a follow up on how these

More information

Introduction to Databases

Introduction to Databases JAVA JDBC Introduction to Databases Assuming you drove the same number of miles per month, gas is getting pricey - maybe it is time to get a Prius. You are eating out more month to month (or the price

More information

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark

Database Access with JDBC. Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark Database Access with JDBC Dr. Jens Bennedsen, Aarhus University, School of Engineering Aarhus, Denmark jbb@ase.au.dk Overview Overview of JDBC technology JDBC drivers Seven basic steps in using JDBC Retrieving

More information

Server-side Web Programming

Server-side Web Programming Server-side Web Programming Lecture 13: JDBC Database Programming JDBC Definition Java Database Connectivity (JDBC): set of classes that provide methods to Connect to a database through a database server

More information

Visit for more.

Visit  for more. Chapter 6: Database Connectivity Informatics Practices Class XII (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By:- Rajesh Kumar Mishra, PGT (Comp.Sc.)

More information

Databases and MySQL. COMP 342: Programming Methods. 16 September Databases and MySQL

Databases and MySQL. COMP 342: Programming Methods. 16 September Databases and MySQL Databases and MySQL COMP 342: Programming Methods 16 September 2008 Databases and MySQL Database basics What is a database? A database consists of some number of tables. Each table consists of field names

More information

Embedded SQL. Introduction

Embedded SQL. Introduction Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

Embedded SQL. Davood Rafiei

Embedded SQL. Davood Rafiei Embedded SQL Davood Rafiei 1 Introduction Basic Idea: Use SQL statements inside a host language (C, C++, Java, ). Advantages: Can do all the fancy things you do in C/C++/Java. Still have the power of SQL.

More information

Package. com.jpbc. Page 1 of 26

Package. com.jpbc. Page 1 of 26 Package com.jpbc Page 1 of 26 com.jpbc.pbstatement com.jpbc Interface PBStatement All Subinterfaces: PdlStatement, PmlStatement, PqlStatement public interface PBStatement extends The object used for executing

More information

SQream Connector JDBC SQream Technologies Version 2.9.3

SQream Connector JDBC SQream Technologies Version 2.9.3 SQream Connector JDBC 2.9.3 SQream Technologies 2019-03-27 Version 2.9.3 Table of Contents The SQream JDBC Connector - Overview...................................................... 1 1. API Reference............................................................................

More information

Relational Database Systems 1

Relational Database Systems 1 Relational Database Systems 1 Wolf-Tilo Balke Simon Barthel Institut für Informationssysteme Technische Universität Braunschweig www.ifis.cs.tu-bs.de Overview Database APIs CLI ODBC JDBC Relational Database

More information

Lab 6-1: MySQL Server

Lab 6-1: MySQL Server Lab 6-1: MySQL Server 1. Objective The participants of the course will be able to: Install and configure a MySQL server. Define a c-program, which enables to access (write and read) to the database of

More information

Enterprise Systems. Lecture 02: JDBC. Behzad BORDBAR

Enterprise Systems. Lecture 02: JDBC. Behzad BORDBAR Enterprise Systems Lecture 02: JDBC Behzad BORDBAR 22 Contents Running example Sample code for beginners Properties to configure Statements and ResultSet Pitfalls of using ResultSet getobject() vs. getxxx()

More information

JDBC. Oracle ODBC SP API SP API. SQL server C function calls. SQL server ODBC SP API. Oracle DSN Oracle ODBC Oracle

JDBC. Oracle ODBC SP API SP API. SQL server C function calls. SQL server ODBC SP API. Oracle DSN Oracle ODBC Oracle How to Interact with DataBase? THETOPPERSWAY.COM Generally every DB vendor provides a User Interface through which we can easily execute SQL query s and get the result (For example Oracle Query Manager

More information

Database Explorer Quickstart

Database Explorer Quickstart Database Explorer Quickstart Last Revision: Outline 1. Preface 2. Requirements 3. Introduction 4. Creating a Database Connection 1. Configuring a JDBC Driver 2. Creating a Connection Profile 3. Opening

More information

SQL: Programming Midterm in class next Thursday (October 5)

SQL: Programming Midterm in class next Thursday (October 5) Announcements (September 28) 2 Homework #1 graded Homework #2 due today Solution available this weekend SQL: Programming Midterm in class next Thursday (October 5) Open book, open notes Format similar

More information

Lecture 9&10 JDBC. Mechanism. Some Warnings. Notes. Style. Introductory Databases SSC Introduction to DataBases 1.

Lecture 9&10 JDBC. Mechanism. Some Warnings. Notes. Style. Introductory Databases SSC Introduction to DataBases 1. Lecture 9&10 JDBC Java and SQL Basics Data Manipulation How to do it patterns etc. Transactions Summary JDBC provides A mechanism for to database systems An API for: Managing this Sending s to the DB Receiving

More information

Database Application Development

Database Application Development Database Application Development Linda Wu (CMPT 354 2004-2) Topics SQL in application code Embedded SQL JDBC SQLJ Stored procedures Chapter 6 CMPT 354 2004-2 2 SQL in Application Code SQL commands can

More information

Real SQL Programming 1

Real SQL Programming 1 Real SQL Programming 1 SQL in Real Programs We have seen only how SQL is used at the generic query interface an environment where we sit at a terminal and ask queries of a database Reality is almost always

More information

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes

Types of Databases. Types of Databases. Types of Databases. Databases and Web. Databases and Web. Relational databases may also have indexes Types of Databases Relational databases contain stuctured data tables, columns, fixed datatype for each column Text databases are available for storing non-structured data typically text databases store

More information