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).
This document provides an overview of connecting to and interacting with databases using JDBC. It begins with database basics, explaining concepts like tables, records, queries, and SQL. It then covers connecting to a database with JDBC, including registering drivers and obtaining a connection. Finally, it discusses querying and manipulating databases with JDBC through executing SQL statements and processing result sets. Examples are provided to demonstrate selecting, updating, and inserting data into databases using 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.
Java applications cannot directly communicate with a database to submit data and retrieve the results of queries.
This is because a database can interpret only SQL statements and not Java language statements.
For this reason, you need a mechanism to translate Java statements into SQL statements.
The JDBC architecture provides the mechanism for this kind of translation.
The JDBC architecture can be classified into two layers :
JDBC application layer.
JDBC driver layer.
JDBC application layer : Signifies a Java application that uses the JDBC API to interact with the JDBC drivers. A JDBC driver is software that a Java application uses to access a database. The JDBC driver manager of JDBC API connects the Java application to the driver.
JDBC driver layer : Acts as an interface between a Java applications and a database. This layer contains a driver , such as a SQL server driver or an Oracle driver , which enables connectivity to a database.
A driver sends the request of a Java application to the database. After processing the request, the database sends the response back to the driver. The driver translates and sends the response to the JDBC API. The JDBC API forwards it to the Java application.
Jdbc example program with access and MySqlkamal kotecha
The document provides examples of using JDBC to connect to and interact with Microsoft Access and MySQL databases. It includes steps to create databases and tables in Access and MySQL, as well as code samples demonstrating how to connect to the databases using JDBC, execute queries using Statement and PreparedStatement, and retrieve and display result sets. Key aspects like loading the appropriate JDBC driver and connection strings for different databases are also explained.
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
The document discusses Java Database Connectivity (JDBC) and how it allows Java programs to connect to databases. It describes the four types of JDBC drivers, the core JDBC interfaces like Driver, Connection, and Statement, and how to use JDBC to perform CRUD operations. The key interfaces allow establishing a database connection and executing SQL statements to retrieve and manipulate data.
This document provides an overview of connecting to and interacting with databases using JDBC. It begins with database basics, explaining concepts like tables, records, queries, and SQL. It then covers connecting to a database with JDBC, including registering drivers and obtaining a connection. Finally, it discusses querying and manipulating databases with JDBC through executing SQL statements and processing result sets. Examples are provided to demonstrate selecting, updating, and inserting data into databases using 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.
Java applications cannot directly communicate with a database to submit data and retrieve the results of queries.
This is because a database can interpret only SQL statements and not Java language statements.
For this reason, you need a mechanism to translate Java statements into SQL statements.
The JDBC architecture provides the mechanism for this kind of translation.
The JDBC architecture can be classified into two layers :
JDBC application layer.
JDBC driver layer.
JDBC application layer : Signifies a Java application that uses the JDBC API to interact with the JDBC drivers. A JDBC driver is software that a Java application uses to access a database. The JDBC driver manager of JDBC API connects the Java application to the driver.
JDBC driver layer : Acts as an interface between a Java applications and a database. This layer contains a driver , such as a SQL server driver or an Oracle driver , which enables connectivity to a database.
A driver sends the request of a Java application to the database. After processing the request, the database sends the response back to the driver. The driver translates and sends the response to the JDBC API. The JDBC API forwards it to the Java application.
Jdbc example program with access and MySqlkamal kotecha
The document provides examples of using JDBC to connect to and interact with Microsoft Access and MySQL databases. It includes steps to create databases and tables in Access and MySQL, as well as code samples demonstrating how to connect to the databases using JDBC, execute queries using Statement and PreparedStatement, and retrieve and display result sets. Key aspects like loading the appropriate JDBC driver and connection strings for different databases are also explained.
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
The document discusses Java Database Connectivity (JDBC) and how it allows Java programs to connect to databases. It describes the four types of JDBC drivers, the core JDBC interfaces like Driver, Connection, and Statement, and how to use JDBC to perform CRUD operations. The key interfaces allow establishing a database connection and executing SQL statements to retrieve and manipulate data.
The document discusses JDBC (Java Database Connectivity) and its architecture. It describes JDBC as a standard Java API that allows Java applications to connect to databases. It outlines the key components of JDBC including the driver manager, drivers, connections, statements, result sets, and how they interact. It also discusses the different types of JDBC drivers and how prepared statements and callable statements work.
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.
There are 4 types of JDBC drivers. Database connections can be obtained using the DriverManager or a DataSource. Statements are used to execute SQL queries and updates. PreparedStatements are useful for executing the same statement multiple times with different parameter values. Joins allow querying data from multiple tables.
The document discusses JDBC (Java Database Connectivity), which provides Java applications with methods to access databases. It covers JDBC architecture and driver types, including Type 1 (JDBC-ODBC bridge), Type 2 (native API), Type 3 (network protocol), and Type 4 (pure Java) drivers. The key classes and interfaces of the JDBC API are also summarized, along with the typical steps to connect to a database using JDBC: loading a driver, connecting, executing statements, and handling exceptions.
JDBC (Java Database Connectivity) is an API that provides Java programs with the ability to connect to and interact with databases. It allows database-independent access to different database management systems (DBMS) using Java programming language. JDBC drivers are used to connect to databases and come in four types depending on how they interface with the database. The basic steps to use JDBC include registering a driver, connecting to the database, executing SQL statements, handling results, and closing the connection. Scrollable result sets and prepared statements are also introduced as advanced JDBC features.
JDBC (Java Database Connectivity) is a Java API that allows Java programs to connect to and interact with relational databases. There are four types of JDBC drivers: JDBC-ODBC bridge drivers, native-API drivers, network-protocol drivers, and database-protocol drivers. The key steps in using JDBC include: 1) loading the appropriate JDBC driver, 2) establishing a connection to the database, 3) creating statement objects to execute queries and updates, 4) executing the statements, 5) processing result sets, and 6) closing all open resources.
JDBC allows Java programs to connect to databases in a standard way. It provides cross-vendor connectivity and data access across relational databases. The key classes and interfaces in JDBC establish database connections, send SQL statements, and process query results. To use JDBC, a program first loads the appropriate driver, gets a connection, creates statements to execute queries and updates, processes the results, and closes the connection. This allows Java applications to access databases in a uniform manner independent of the underlying database.
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.
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.
The document discusses database connectivity between a front-end interface and back-end database. It explains that the front-end is the user interface where data is entered, and the back-end is an invisible database that stores and provides data to the application. It then outlines the key components needed for connectivity - the JDBC API and driver to allow Java applications to interact with MySQL databases. The final sections describe classes used for connectivity like DriverManager, Connection, Statement, and ResultSet, and the typical steps to set up connectivity in a Java application.
The document outlines Java Database Connectivity (JDBC) and its key concepts. JDBC provides a standard interface for connecting Java applications to various databases. It defines APIs for establishing a connection to a database, issuing queries and updates, and processing result sets. The document discusses the JDBC architecture, driver types, and interfaces like Connection, Statement, PreparedStatement, CallableStatement, and ResultSet.
JDBC provides a standard interface for connecting to relational databases from Java applications. It establishes a connection with a database, allows sending SQL statements to it, and processing the results. The key classes and interfaces in JDBC are located in the java.sql package. JDBC supports connecting to all major databases and provides a consistent API for database access.
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.
The document discusses JDBC and provides information on its objectives, architecture, drivers, API, and how to create JDBC applications. The key points covered are that JDBC has two layers - the application layer and driver layer; there are four types of JDBC drivers; and the main steps to create a JDBC application are to load a driver, connect to a database, create and execute statements, and handle exceptions.
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.
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 (Java Database Connectivity) provides APIs for Java programs to connect to databases. There are four types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses a native API, Type 3 is pure Java using a network protocol, and Type 4 is also pure Java using a native database protocol.
To connect to a database using JDBC, a program loads the appropriate JDBC driver, gets a connection, creates statements to execute SQL queries and updates, processes the result set, and closes resources. Prepared statements can be used for repetitive queries to improve performance over regular statements. Overall, JDBC allows Java applications to connect to databases in a standardized way
The document discusses JDBC (Java Database Connectivity) and its architecture. It describes JDBC as a standard Java API that allows Java applications to connect to databases. It outlines the key components of JDBC including the driver manager, drivers, connections, statements, result sets, and how they interact. It also discusses the different types of JDBC drivers and how prepared statements and callable statements work.
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.
There are 4 types of JDBC drivers. Database connections can be obtained using the DriverManager or a DataSource. Statements are used to execute SQL queries and updates. PreparedStatements are useful for executing the same statement multiple times with different parameter values. Joins allow querying data from multiple tables.
The document discusses JDBC (Java Database Connectivity), which provides Java applications with methods to access databases. It covers JDBC architecture and driver types, including Type 1 (JDBC-ODBC bridge), Type 2 (native API), Type 3 (network protocol), and Type 4 (pure Java) drivers. The key classes and interfaces of the JDBC API are also summarized, along with the typical steps to connect to a database using JDBC: loading a driver, connecting, executing statements, and handling exceptions.
JDBC (Java Database Connectivity) is an API that provides Java programs with the ability to connect to and interact with databases. It allows database-independent access to different database management systems (DBMS) using Java programming language. JDBC drivers are used to connect to databases and come in four types depending on how they interface with the database. The basic steps to use JDBC include registering a driver, connecting to the database, executing SQL statements, handling results, and closing the connection. Scrollable result sets and prepared statements are also introduced as advanced JDBC features.
JDBC (Java Database Connectivity) is a Java API that allows Java programs to connect to and interact with relational databases. There are four types of JDBC drivers: JDBC-ODBC bridge drivers, native-API drivers, network-protocol drivers, and database-protocol drivers. The key steps in using JDBC include: 1) loading the appropriate JDBC driver, 2) establishing a connection to the database, 3) creating statement objects to execute queries and updates, 4) executing the statements, 5) processing result sets, and 6) closing all open resources.
JDBC allows Java programs to connect to databases in a standard way. It provides cross-vendor connectivity and data access across relational databases. The key classes and interfaces in JDBC establish database connections, send SQL statements, and process query results. To use JDBC, a program first loads the appropriate driver, gets a connection, creates statements to execute queries and updates, processes the results, and closes the connection. This allows Java applications to access databases in a uniform manner independent of the underlying database.
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.
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.
The document discusses database connectivity between a front-end interface and back-end database. It explains that the front-end is the user interface where data is entered, and the back-end is an invisible database that stores and provides data to the application. It then outlines the key components needed for connectivity - the JDBC API and driver to allow Java applications to interact with MySQL databases. The final sections describe classes used for connectivity like DriverManager, Connection, Statement, and ResultSet, and the typical steps to set up connectivity in a Java application.
The document outlines Java Database Connectivity (JDBC) and its key concepts. JDBC provides a standard interface for connecting Java applications to various databases. It defines APIs for establishing a connection to a database, issuing queries and updates, and processing result sets. The document discusses the JDBC architecture, driver types, and interfaces like Connection, Statement, PreparedStatement, CallableStatement, and ResultSet.
JDBC provides a standard interface for connecting to relational databases from Java applications. It establishes a connection with a database, allows sending SQL statements to it, and processing the results. The key classes and interfaces in JDBC are located in the java.sql package. JDBC supports connecting to all major databases and provides a consistent API for database access.
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.
The document discusses JDBC and provides information on its objectives, architecture, drivers, API, and how to create JDBC applications. The key points covered are that JDBC has two layers - the application layer and driver layer; there are four types of JDBC drivers; and the main steps to create a JDBC application are to load a driver, connect to a database, create and execute statements, and handle exceptions.
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.
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 (Java Database Connectivity) provides APIs for Java programs to connect to databases. There are four types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses a native API, Type 3 is pure Java using a network protocol, and Type 4 is also pure Java using a native database protocol.
To connect to a database using JDBC, a program loads the appropriate JDBC driver, gets a connection, creates statements to execute SQL queries and updates, processes the result set, and closes resources. Prepared statements can be used for repetitive queries to improve performance over regular statements. Overall, JDBC allows Java applications to connect to databases in a standardized way
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 Java Database Connectivity (JDBC) API which defines how Java programs can communicate with databases. It describes key JDBC concepts like drivers, packages, and products. It also covers JDBC design considerations like different types of drivers and client-server models. Basic steps to use JDBC include loading drivers, establishing connections, executing statements, and closing connections.
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.
This document provides an overview of database connectivity in Java. It discusses how Java applications can connect to databases using the JDBC API. It describes the different types of JDBC drivers (types I-IV) and how they work. The key steps in a JDBC program are outlined, including loading a driver, establishing a connection, creating statements, executing queries, and processing result sets. Common SQL statements like SELECT, INSERT, UPDATE and DELETE are explained. Overall, the document serves as an introduction to using the JDBC API to connect Java applications to various database management systems.
The document provides an overview of J2EE (Java 2 Enterprise Edition) and its core technologies including JDBC, Servlets, JSP, EJB, and RMI. It then discusses JDBC in more detail, explaining the JDBC architecture, drivers, and basic steps to access a database using JDBC including loading drivers, connecting, executing statements, processing results, and closing connections. It also covers PreparedStatement and CallableStatement objects.
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.
The document discusses Java Database Connectivity (JDBC), which provides a standard interface for connecting to relational databases from Java applications. It describes the JDBC model and programming steps, which include loading a JDBC driver, connecting to a database, executing SQL statements via a Statement object, processing query results stored in a ResultSet, and closing connections. It also covers JDBC driver types, the roles of core classes like Connection and Statement, and transaction handling with JDBC.
This document provides an overview of JDBC (Java Database Connectivity) including ODBC, the JDBC API, JDBC architecture and drivers, and the basic steps for using JDBC to connect to and query a database.
Database Programming: The Design of JDBC, The Structured Query Language, Basic JDBC Programming Concepts,
Result Sets, Metadata, Row Sets, Transactions
Java programming presentations By Daroko blog
Do not just read java as a programmer, find projects and start making some Money, at DAROKO BLOG,WE Guide you through what you have learned in the classroom to a real business Environment, find java applications to a real business Environment, find also all IT Solutions and How you can apply them, find the best companies where you can get the IT jobs worldwide, Find java contract, Complete and start making some cash, find clients within your Country, refer and get paid when you complete the work.
Not Just a contact, at daroko Blog (www.professionalbloggertricks.com/),you are also being taught how you can apply all IT related field in real world.
Simply Google, Daroko Blog or visit (www.professionalbloggertricks.com/) to Know More about all these service now.
Do not just learn and go, apply them in real world.
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.
This document discusses JDBC (Java Database Connectivity), which defines how Java programs can access databases. It describes the four types of JDBC drivers that convert Java requests into protocols understood by different database systems. It also explains how to load JDBC drivers at runtime, make database connections using the DriverManager, execute SQL queries with Statement objects to retrieve ResultSets, and move between rows in a ResultSet using a cursor.
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.
The document provides an overview of the Java Database Connectivity (JDBC) API. It discusses that JDBC allows Java applications to connect to relational databases and execute SQL statements. It describes the different types of JDBC drivers and the core JDBC classes like Connection, Statement, ResultSet, and their usage. The steps to connect to a database and execute queries using JDBC are outlined. Key concepts like processing result sets, handling errors, batch processing, stored procedures are also summarized.
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.
This document discusses Java Database Connectivity (JDBC) which provides Java applications with an API for accessing databases. It describes the four types of JDBC drivers: Type 1 uses JDBC-ODBC bridge, Type 2 uses native database APIs, Type 3 communicates through a middle-tier server, and Type 4 communicates directly via sockets. The document also outlines the basic steps to use JDBC for database connectivity including loading a driver, establishing a connection, creating statements, executing SQL, and processing result sets.
The document provides an overview of object-oriented programming concepts in Python including defining classes, inheritance, methods, and data structures. Some key points:
- Classes define user-created data types that bundle together data (attributes) and functions (methods) that work with that data. Objects are instances of classes.
- Methods are defined within classes and must have "self" as the first argument to access attributes. The __init__ method serves as a constructor.
- Inheritance allows subclasses to extend existing classes, redefining or calling parent methods.
- Python supports lists, tuples, dictionaries, sets and other data structures that can be used to store and organize data. Lists are mutable while tuples are immutable.
This document provides an overview of the Python programming language. It discusses Python's history, features, and why it is a good programming language. Key points covered include:
- Python was created in the late 1980s and draws from many other languages.
- It is an open source, interpreted, object-oriented, and portable language with a large online community and library support.
- Python code is compiled to bytecode for performance. It has dynamic typing, automatic memory management, and is powerful yet easy to learn.
- The document reviews Python statements, expressions, variables, basic data types, functions, modules and exceptions. It provides examples of Python code.
The document discusses various topics related to shell programming and scripting languages including:
1. It provides an overview of HTML, the basic building blocks of websites including tags, elements and page structure.
2. It describes common HTML tags for text formatting, headings, and other page elements. It also discusses HTML forms and how to pass data.
3. It provides an introduction to CGI (Common Gateway Interface) and how it allows information to be exchanged between a web server and custom scripts to dynamically generate web pages.
4. It includes examples of basic CGI programs in Python for handling GET and POST requests, retrieving and displaying form data, and using cookies to maintain state across web requests.
This document provides information about the Python programming language. It discusses the features of Python, including that it is object-oriented, open source, portable, powerful, and easy to learn. It also covers Python syntax, statements, functions, modules, exception handling, and how to run Python programs. The outcomes of learning these Python concepts are also listed.
The document discusses object-oriented programming in Python. It defines key OOP concepts like classes, objects, and methods. It provides examples of defining classes and methods in Python. It also covers inheritance, polymorphism, and data abstraction in OOP. Database programming in Python is also discussed, including connecting to databases and performing CRUD operations using the Python DB API.
This document provides an overview of shell programming and scripting languages. It discusses the responsibilities of shells, including customizing the work environment, automating tasks, and executing system procedures. Key shell concepts covered include pipes, input/output redirection, variables, control structures, arithmetic, functions, and debugging scripts. The document also describes common shell types like Bourne, C, Korn, and Bash shells and provides examples of using meta characters, variables, condition tests, and control statements in shell scripts.
This document provides information about a course on Shell Programming and Scripting Languages. It discusses:
- The course objectives which are to explain UNIX commands, implement shell scripts using Bash, and learn Python scripting.
- The course outcomes which are to understand UNIX commands and utilities, write and execute shell scripts, handle files and processes, and learn Python programming and web application design.
- Prerequisites of DOS commands and C programming.
- An overview of UNIX including the file system, vi editor, and security permissions.
The document discusses various shell scripting tools including grep, sed, and awk. It provides descriptions and examples of how to use grep to search for patterns in files using regular expressions. It also covers sed for stream editing to find and replace text. Finally, it discusses awk for text processing and programming with actions based on patterns in fields and records.
The document provides information on servlet fundamentals including definitions, applications, architecture, lifecycle, and development process. Some key points include:
- Servlets are Java programs that run on web servers and interact with clients via HTTP requests and responses. They provide dynamic content and process user input.
- Common servlet applications include search engines, e-commerce sites, and intranets.
- The servlet lifecycle includes initialization, processing requests, and destruction. Servlets remain loaded in memory between requests for improved performance over CGI.
- To develop a servlet, you create a class that implements the Servlet interface, define request handling methods, compile it, deploy it in a web container
The document discusses web servers and their role in handling HTTP requests and responses. A web server manages files and directories, communicates with clients, and delegates requests to server-side programs like servlets, JSPs, and ASPs to generate dynamic responses. An application server exposes business logic through APIs and manages additional resources like security, transactions, and messaging. Tomcat is an example of a web server that can deploy servlets by placing class files in directories and starting the server.
The document discusses web servers and their role in handling HTTP requests and responses. A web server manages files, directories, permissions and communicates with client computers. It may respond directly with HTML or delegate request processing to programs like servlets, JSPs or ASPs. An application server exposes business logic through APIs and manages resources like security, transactions and messaging. The Tomcat web server is described for deploying servlets, including putting class files in the proper directory and starting the server.
The document describes servlets and how they work. It includes:
- An overview of servlets, including the servlet interface, life cycle, and HttpServlet class for handling HTTP requests
- Explanation of how servlets receive and respond to HTTP requests through the HttpServletRequest and HttpServletResponse interfaces
- An example servlet called WelcomeServlet that handles GET requests and generates an XHTML response page to demonstrate servlet basics
This document contains 29 multiple choice and fill-in-the-blank questions about XML, DTD, XML Schema, XSLT, parsers, and related web technologies. It tests knowledge of topics like the meaning of XML and its acronyms, how to structure XML documents and link style sheets, XML data types, namespaces, facets, parsers, and the differences between DOM and SAX. The questions cover essential concepts, syntax, and applications of XML and its related specifications that are important for understanding web technologies.
The document contains a quiz on web technologies like HTML, CSS, JavaScript, HTTP, and related concepts. It asks 43 multiple choice and short answer questions covering topics such as the purpose of HTML, CSS, HTTP, and JavaScript; HTML tags for headings, links, and formatting; CSS types; JavaScript functions, objects, and statements; and differences between technologies like JavaScript and Java. The questions are testing understanding of basic building blocks of web design and programming.
This document contains a quiz on servlets and web technologies. It asks questions about defining servlets, the responsibilities of a web server, the protocol used for browsing, the types and lifecycle of servlets, HTML in HTTP requests, HTTP methods, servlet pages, differences between applets and servlets, cookies, session tracking, servlet programming steps, differences between generic and HTTP servlets, web servers, setting paths, installing Tomcat, the printwriter() method, input/output streams, and stateless protocols.
This document contains 29 multiple choice and fill-in-the-blank questions about XML, DTD, XML Schema, XSLT, parsers, and related web technologies. It tests knowledge of topics like what XML stands for, how to describe XML data, XML declaration statements, DTD definition, XML case sensitivity, whitespace handling, XSLT definition, data types in XML Schema, linking style sheets, XML comments, document elements, DTD data types, entities and attributes, DTD disadvantages, XML Schema definition, Schema file extensions, Schema support for websites, namespaces, Schema data type categories, schema definition statements, XSL definition, including DTD and XSL programs in XML, facets, parsers, XML parser types
The document contains a quiz on web technologies like HTML, CSS, JavaScript, HTTP, and related concepts. It asks 43 multiple choice and short answer questions covering topics such as the purpose of various web protocols and languages, HTML tags and attributes, CSS types, JavaScript functions, objects, and statements. The questions are testing understanding of foundational elements of web design and programming.
JSP (Java Server Pages) is a technology that allows the creation of dynamic web pages by embedding Java code in HTML pages. This provides a simpler way to add dynamic content to web pages compared to servlets. Some key points:
- JSP pages allow embedding of Java code in HTML pages using scripting elements like <% %> tags. This separates dynamic content from static content.
- JSP pages are compiled to servlets, separating the work of Java programmers and page authors.
- Common JSP elements include scriptlets, expressions, declarations, and directives that control things like page attributes and included files.
- JSP provides built-in support for HTTP sessions and can integrate with Java
The document discusses XML (eXtensible Markup Language), its differences from HTML, and its uses and advantages. XML was designed to carry and store data, unlike HTML which was designed to display data. XML allows users to define their own elements and tags to structure information. It simplifies data sharing and transport between different platforms. XML schemas provide more power and flexibility than DTDs in defining XML documents and element structures.
JavaScript is a scripting language that allows adding interactivity to HTML pages. It was originally developed by Netscape as a means to add dynamic content to web pages. JavaScript can be used to create client-side applications, enhance HTML pages with dynamic effects, validate forms, connect to databases, and more. Some key points about JavaScript include that it is embedded directly into HTML, interpreted rather than compiled, loosely typed, object-based, and event-driven. Common JavaScript objects include Window, Document, Location, Form, and more that correspond to HTML elements.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Building RAG with self-deployed Milvus vector database and Snowpark Container...Zilliz
This talk will give hands-on advice on building RAG applications with an open-source Milvus database deployed as a docker container. We will also introduce the integration of Milvus with Snowpark Container Services.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
20 Comprehensive Checklist of Designing and Developing a WebsitePixlogix Infotech
Dive into the world of Website Designing and Developing with Pixlogix! Looking to create a stunning online presence? Look no further! Our comprehensive checklist covers everything you need to know to craft a website that stands out. From user-friendly design to seamless functionality, we've got you covered. Don't miss out on this invaluable resource! Check out our checklist now at Pixlogix and start your journey towards a captivating online presence today.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
In the rapidly evolving landscape of technologies, XML continues to play a vital role in structuring, storing, and transporting data across diverse systems. The recent advancements in artificial intelligence (AI) present new methodologies for enhancing XML development workflows, introducing efficiency, automation, and intelligent capabilities. This presentation will outline the scope and perspective of utilizing AI in XML development. The potential benefits and the possible pitfalls will be highlighted, providing a balanced view of the subject.
We will explore the capabilities of AI in understanding XML markup languages and autonomously creating structured XML content. Additionally, we will examine the capacity of AI to enrich plain text with appropriate XML markup. Practical examples and methodological guidelines will be provided to elucidate how AI can be effectively prompted to interpret and generate accurate XML markup.
Further emphasis will be placed on the role of AI in developing XSLT, or schemas such as XSD and Schematron. We will address the techniques and strategies adopted to create prompts for generating code, explaining code, or refactoring the code, and the results achieved.
The discussion will extend to how AI can be used to transform XML content. In particular, the focus will be on the use of AI XPath extension functions in XSLT, Schematron, Schematron Quick Fixes, or for XML content refactoring.
The presentation aims to deliver a comprehensive overview of AI usage in XML development, providing attendees with the necessary knowledge to make informed decisions. Whether you’re at the early stages of adopting AI or considering integrating it in advanced XML development, this presentation will cover all levels of expertise.
By highlighting the potential advantages and challenges of integrating AI with XML development tools and languages, the presentation seeks to inspire thoughtful conversation around the future of XML development. We’ll not only delve into the technical aspects of AI-powered XML development but also discuss practical implications and possible future directions.
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
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. Advantages
1. Simplified Enterprise Development:
By integrating with java JDBC code becomes very less. It is
simple to install and maintain. Easy to write JDBC program
2. Zero Configuration for Network computers:
No configuration is required. We require a suitable driver to
connect to the database. It may be a bridge driver or a driver
written in java.
3. Full Access to Metadata: JDBC API includes classes
and interfaces to obtain metadata.
4. No Installation:
4. 5. Database connection identified by URL: connectivity
through DataSource object. Data source objects can provide
connection pooling and transaction management.
6. Included in the J2EE platform: As JDBC API is needed in
enterprise applications to connect to databases, it is included in
the java2.0 Enterprise Edition.
Advantages
5. JDBC API
It contains two main interfaces.
1. An API for application writers and
2. A lower level driver API for driver writers.
The set of classes that implement these lower level API
interfaces for a particular database engine is called a
JDBC driver
A program needs a specific driver to connect to a specific
database
6. Popular Drivers
Driver RDBMS
Oracle.jdbc.driver.OracleDriver ORACLE
Com.mysql.jdbc.Driver MySQL
Com.sybase.jdbc.SybDriver Sybase
Com.microsoft.jdbc.sqlserver.SQLServer
Driver
SQL Server
Com.ibm.db2.jdbc.net.DB2Driver DB2
Org.hsqldbJdbcDriver HSQL DB
7. Types of Drivers
1. Type1 ( JDBC-ODBC bridge + ODBC driver)
2. Type2 (partial JDBC driver)
3. Type3 (pure java JDBC driver for database
middleware)
4. Type4 (pure Java JDBC driver with a direct
database connection)
8. Type 1 driver
Allows an application to access database through an
intermediate ODBC driver.
It provides a gateway to the ODBC API
Disadvantages:
1. ODBC binary code must be loaded on each client
machine that uses this driver, limiting the usefulness of
this type of driver for the internet
2. Translation overhead between JDBC and ODBC
3. User is limited by the functionality of the underlying ODBC
driver.
4. Doesn’t support all the features of java.
5. It only works under the Microsoft windows and Sun
Solaris operating systems.
9. Type 2, 3,4 Drivers
Type 2-driver converts JDBC calls into client API calls for
the DBMS. Also communicates directly with the database
server. This driver offers better performance than type 1
driver.
Type-3 driver is completely implemented in java, hence it
is a pure java JDBC driver. It translates JDBC calls into
the middleware vendors’ protocol and translated to a
DBMS protocol by a middleware server.
Type-4 drivers talks directly to the database using java
sockets. These type of drivers are completely
implemented in java to achieve platform independence
and eliminate deployment issues. This type of drivers
comes from the database vendor.
10. 10
General Architecture
What design pattern is
implied in this
architecture?
What does it buy for us?
Why is this architecture
also multi-tiered?
12. 12
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
13. 13
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:@oracl
e-prod:1521:OPROD", username, passwd);
What do you think this statement does?
Establishes connection to database by obtaining
a Connection object
14. 14
2. Create JDBC statement(s)
Statement stmt = con.createStatement() ;
Creates a Statement object for sending SQL statements
to the database
15. 15
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);
16. 16
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");
}
18. 18
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.
19. 19
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
20. 20
Another way to access database
(JDBC-ODBC)
What’s a bit different
about this
architecture?
Why add yet
another layer?
21. 21
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");
22. 22
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); }
}
}
24. 24
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
…
25. 25
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();
}
26. 26
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.
28. 28
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) );
}
}
29. 29
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
30. JDBC API
PreparedStatement
• Represents a precompiled SQL statement
• Can be used to efficiently execute
statement multiple times
• Somewhat flexible – can create new ones
as needed
A prepared statement can contain variables that
you supply each time you execute the statement.
31. Optimized Statements
Prepared Statements
SQL calls that you make again and again
allows driver to optimize (compile) queries
created with Connection.prepareStatement()
Stored Procedures
written in DB-specific language
stored inside database
accessed with Connection.prepareCall()
32. Prepared Statements Performance
Prepared Statements are more
efficient than Statements when
executing SQL statements multiple times
and with different parameter values.
34. PreparedStatements
PreparedStatement to locate all book titles for
an author with a specific last name and first name,
and to execute that query for several authors:
PreparedStatement authorBooks =
connection.prepareStatement(
"SELECT lastName, firstName, title " +
"FROM authors INNER JOIN authorISBN " +
"ON authors.authorID=authorISBN.authorID "
+
"INNER JOIN titles " +
"ON authorISBN.isbn=titles.isbn " +
"WHERE lastName = ? AND firstName = ?" );
Question marks (?) are placeholders for values that
will be passed as part of the query to the database
35. PreparedStatements
Program must specify the parameter values by
using the PreparedStatement interface’s set
methods.
For the preceding query, both parameters are
strings that can be set with PreparedStatement
method setString as follows:
authorBooks.setString( 1, "Deitel" );
authorBooks.setString( 2, "Paul" );
setString automatically escapes String
parameter values as necessary (e.g., the quote in
the name O’Brien)
36. Prepared Statement Example
PreparedStatement updateSales;
String updateString = "update COFFEES " +
"set SALES = ? where COF_NAME like ?";
updateSales = con.prepareStatement(updateString);
int [] salesForWeek = {175, 150, 60, 155, 90};
String [] coffees = {"Colombian", "French_Roast",
"Espresso","Colombian_Decaf","French_Roast_Decaf"};
int len = coffees.length;
for(int i = 0; i < len; i++) {
updateSales.setInt(1, salesForWeek[i]);
updateSales.setString(2, coffees[i]);
updateSales.executeUpdate();
}
38. The Callable Statement Object
A Callable Statement object holds parameters
for calling stored procedures.
A callable statement can contain variables that
you supply each time you execute the call.
When the stored procedure returns, computed
values (if any) are retrieved through the
Callable Statement object.
40. CallableStatement cstmt =
conn.prepareCall("{call " +
ADDITEM + "(?,?,?)}");
cstmt.registerOutParameter(2,Types.INTEGER);
cStmt.registerOutParameter(3,Types.DOUBLE);
How to Create a Callable
Statement
Register the driver and create the database
connection.
Create the callable statement, identifying
variables with a question mark (?).
41. How to Execute
a callable
Statement
How to Execute
a callable
Statement
cstmt.setXXX(index, value);
cstmt.execute(statement);
var = cstmt.getXXX(index);
43. Three-Tier Architecture
Oracle
DB Server
Apache Tomcat
App Server
Microsoft
Internet
Explorer
HTML
Tuples
HTTP
Requests
JDBC
Requests
Java Server
Pages (JSPs)
Located
@ DBLab
Located
@ Your PC
Located
@ Any PC
44. import java.sql.*;
class JdbcTest {
public static void main (String args []) throws SQLException {
// Load Oracle driver
DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());
// Connect to the local database
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@myhost:1521:ORCL","scott", "tiger");
JDBC
45. // Query the student names
Statement stmt = conn.createStatement ();
ResultSet rset = stmt.executeQuery ("SELECT name FROM Student");
// Print the name out
//name is the 2nd
attribute of Student
while (rset.next ())
System.out.println (rset.getString (2));
//close the result set, statement, and the connection
rset.close();
stmt.close();
conn.close();
47. Entry Form - First Attempt
<b>Data Entry Menu</b>
<ul>
<li>
<a href="courses.jsp">Courses<a>
</li>
<li>
<a href="classes.jsp">Classes<a>
</li>
<li>
<a href="students.jsp">Students<a>
</li>
</ul>
Menu HTML Code
48. Entry Form - First Attempt
<html>
<body>
<table>
<tr>
<td>
<jsp:include page="menu.html" />
</td>
<td>
Open connection code
Statement code
Presentation code
Close connection code
</td>
</tr>
</table>
</body>
</html>
JSP Code
49. Entry Form - First Attempt
<%-- Set the scripting language to java and --%>
<%-- import the java.sql package --%>
<%@ page language="java" import="java.sql.*" %>
<%
try {
// Load Oracle Driver class file
DriverManager.registerDriver
(new oracle.jdbc.driver.OracleDriver());
// Make a connection to the Oracle datasource
Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@feast.ucsd.edu:1521:source",
“user", “pass");
%>
Open Connectivity Code
50. Entry Form - First Attempt
<%
// Create the statement
Statement statement = conn.createStatement();
// Use the statement to SELECT the student attributes
// FROM the Student table.
ResultSet rs = statement.executeQuery
("SELECT * FROM Student");
%>
Statement Code
51. Entry Form - First Attempt
<table>
<tr>
<th>SSN</th>
<th>First</th>
<th>Last</th>
<th>College</th>
</tr>
<%
// Iterate over the ResultSet
while ( rs.next() ) {
%>
Iteration Code
<%
}
%>
</table>
Presentation Code
53. Entry Form - First Attempt
<tr>
<%-- Get the SSN, which is a number --%>
<td><%= rs.getInt("SSN") %></td>
<%-- Get the ID --%>
<td><%= rs.getString("ID") %></td>
<%-- Get the FIRSTNAME --%>
<td><%= rs.getString("FIRSTNAME") %></td>
<%-- Get the LASTNAME --%>
<td><%= rs.getString("LASTNAME") %></td>
<%-- Get the COLLEGE --%>
<td><%= rs.getString("COLLEGE") %></td>
</tr>
Iteration Code
54. Entry Form - First Attempt
<%
// Close the ResultSet
rs.close();
// Close the Statement
statement.close();
// Close the Connection
conn.close();
} catch (SQLException sqle) {
out.println(sqle.getMessage());
} catch (Exception e) {
out.println(e.getMessage());
}
%>
Close Connectivity Code
56. Entry Form - Second Attempt
<html>
<body>
<table>
<tr>
<td>
Open connection code
Insertion Code
Statement code
Presentation code
Close connection code
</td>
</tr>
</table>
</body>
</html>
JSP Code
57. Entry Form - Second Attempt
// Check if an insertion is requested
String action = request.getParameter("action");
if (action != null && action.equals("insert")) {
conn.setAutoCommit(false);
// Create the prepared statement and use it to
// INSERT the student attrs INTO the Student table.
PreparedStatement pstmt = conn.prepareStatement(
("INSERT INTO Student VALUES (?, ?, ?, ?, ?)"));
pstmt.setInt(1,Integer.parseInt(request.getParameter("SSN")));
pstmt.setString(2, request.getParameter("ID"));
…
pstmt.executeUpdate();
conn.commit();
conn.setAutoCommit(true);
}
Insertion Code
58. Entry Form - Second Attempt
<table>
<tr>
<th>SSN</th>
<th>First</th>
<th>Last</th>
<th>College</th>
</tr>
Insert Form Code
<%
// Iterate over the ResultSet
while ( rs.next() ) {
%>
Iteration Code
<%
}
%>
</table>
Presentation Code
61. Entry Form - Third Attempt
<html>
<body>
<table>
<tr>
<td>
Open connection code
Insertion Code
Update Code
Delete Code
Statement code
Presentation code
Close connection code
</td>
</tr>
</table>
</body>
</html>
JSP Code
62. Entry Form - Third Attempt
// Check if an update is requested
if (action != null && action.equals("update")) {
conn.setAutoCommit(false);
// Create the prepared statement and use it to
// UPDATE the student attributes in the Student table.
PreparedStatement pstatement = conn.prepareStatement(
"UPDATE Student SET ID = ?, FIRSTNAME = ?, " +
"LASTNAME = ?, COLLEGE = ? WHERE SSN = ?");
pstatement.setString(1, request.getParameter("ID"));
pstatement.setString(2, request.getParameter("FIRSTNAME"));
…
int rowCount = pstatement.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);
}
Update Code
63. Entry Form - Third Attempt
// Check if a delete is requested
if (action != null && action.equals("delete")) {
conn.setAutoCommit(false);
// Create the prepared statement and use it to
// DELETE the student FROM the Student table.
PreparedStatement pstmt = conn.prepareStatement(
"DELETE FROM Student WHERE SSN = ?");
pstmt.setInt(1,
Integer.parseInt(request.getParameter("SSN")));
int rowCount = pstmt.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);
}
Delete Code
64. Entry Form - Third Attempt
<table>
<tr>
<th>SSN</th>
<th>First</th>
<th>Last</th>
<th>College</th>
</tr>
Insert Form Code
<%
// Iterate over the ResultSet
while ( rs.next() ) {
%>
Iteration Code
<%
}
%>
</table>
Presentation Code
The CallableStatement Object
The way to access stored procedures using JDBC is through the CallableStatement class which is inherited from the PreparedStatement class. CallableStatement is like PreparedStatement in that you can specify parameters using the question mark (?) notation, but it contains no SQL statements.
Both functions and procedures take parameters represented by identifiers. A function executes some procedural logic and it returns a value that can be any data type supported by the database. The parameters supplied to the function do not change after the function is executed.
A procedure executes some procedural logic but does not return any value. However, some of the parameters supplied to the procedure may have their values changed after the procedure is executed.
Note: Calling a stored procedure is the same whether the stored procedure was written originally in Java or in any other language supported by the database, such as PL/SQL. Indeed, a stored procedure written in Java appears to the programmer as a PL/SQL stored procedure.
Creating a Callable Statement
First you need an active connection to the database in order to obtain a CallableStatement object.
Next, you create a CallableStatement object using the prepareCall() method of the Connection class. This method typically takes a string as an argument. The syntax for the string has two forms. The first form includes a result parameter and the second form does not:
{? = call proc (…) } // A result is returned into a variable{call proc (…) } // Does not return a result
In the example in the slide, the second form is used, where the stored procedure in question is ADDITEM.
Note that the parameters to the stored procedures are specified using the question mark notation used earlier in PreparedStatement. You must register the data type of the parameters using the registerOutParameter() method of CallableStatement if you expect a return value, or if the procedure is going to modify a variable (also known as an OUT variable). In the example in the slide, the second and third parameters are going to be computed by the stored procedure, whereas the first parameter is an input (the input is specified in the next slide). Parameters are referred to sequentially, by number. The first parameter is 1.
To specify the data type of each OUT variable, you use parameter types from the Types class. When the stored procedure successfully returns, the values can be retrieved from the CallableStatement object.
How to Execute a Callable Statement
There are three steps in executing the stored procedure after you have registered the types of the OUT variables:
1.Set the IN parameters.
Use the setXXX() methods to supply values for the IN parameters. There is one setXXX() method for each Java type: setString(), setInt(), and so on. You must use the setXXX() method that is compatible with the SQL type of the variable. You can use setObject() with any variable type. Each variable has an index. The index of the first variable in the prepared statement is 1, the index of the second is 2, and so on. If there is only one variable, its index is 1.
2.Execute the call to the stored procedure.
Execute the procedure using the execute() method.
3.Get the OUT parameters.
Once the procedure is completed, you retrieve OUT variables, if any, using the getXXX() methods. Note that these methods must match the types you registered in the previous slide.
Instructor Note
The stored procedures lesson contains an example of executing a callable statement.