Lecture 13 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Java Course 12: XML & XSL, Web & ServletsAnton Keks
Lecture 12 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Lecture 15 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview of more advanced Java topics.
Java Course 7: Text processing, Charsets & EncodingsAnton Keks
Lecture 7 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Do you know the difference between charset & encoding? Every programmer nowadays MUST understand these terms, how they work, and how to use them. Otherwise we constantly face broken software refusing to work with international characters properly.
Lecture 14 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Lecture 6 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview how a software developer should organize their daily work, apart from technical skills.
Introduces Agile software development practices from XP and Scrum.
Lecture 3 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Discusses more Java basics and Object Oriented Programming.
Java Course 12: XML & XSL, Web & ServletsAnton Keks
Lecture 12 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Lecture 15 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview of more advanced Java topics.
Java Course 7: Text processing, Charsets & EncodingsAnton Keks
Lecture 7 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Do you know the difference between charset & encoding? Every programmer nowadays MUST understand these terms, how they work, and how to use them. Otherwise we constantly face broken software refusing to work with international characters properly.
Lecture 14 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Lecture 6 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview how a software developer should organize their daily work, apart from technical skills.
Introduces Agile software development practices from XP and Scrum.
Lecture 3 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Discusses more Java basics and Object Oriented Programming.
Lecture 11 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Describes goods and bads of software architecture as well as common design patterns.
Core Java introduction | Basics | free course Kernel Training
http://kerneltraining.com/core-java/
Learn the basics of Java and gain practical experience that is required to begin your career in java programming. Kernel Training has designed classroom and online course to upgrade your knowledge and skills in core Java.
Course Curriculum:
Introduction to Java
JDK and practical applications
Java Basic Data Types and Operators
Programming Constructs, Classes and Methods, constructor and Finalizer
Polymorphism
Inheritance
Method overriding and abstract classes
Packages and Interfaces
Strings and Arrays
Enums
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
16. Threads in Java
Non-Threaded Applications
Threaded Applications
Process based multitasking Vs Thread based multitasking
Thread API in Java
Creating Threads
States of a Thread
Synchronization for threads; static and non-static synchronized methods; blocks; concept of object and class locks
Coordination between threads - wait, notify and notifyAll methods for inter-thread communication
17. Applets
What are applets?
Need for Applets
Different ways of running an applet program
Applet API hierarchy
Life Cycle of an applet
Even Handlers for applets, mouse events, click events
18. Swing GUI
Introduction to AWT
Introduction to Swing GUI
Advantages of Swing over AWT
Swing API
Swing GUI Components
Event Handlers for Swing
Sample Calculator application using Swing GUI and Swing Event handling
19. JDBC
What is JDBC; introduction
JDBC features
JDBC Drivers
Setting up a database and creating a schema
Writing JDBC code to connect to DB
CRUD Operations with JDBC
Statement types in JDBC
Types of Rowset, ResultSet in JDBC
20. Access Modifiers in Java
What are access modifiers?
Default
Protected
Private
Public
Core Java Tutorial. In case you want to get trained in Spring Framework you can refer here:
<a href="https://www.emexotechnologies.com/courses/java-development-training/core-java-training/">Java Training</a>
In this presentation we introduce topic of core java that is required to learn if you want to be good java programmer. i provide all concept in detail.
Learn JAVA tutorial -This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions by PSK Technologies located in Nagpur that provides best training in Java,PHP,Web Development Hardware and Networking and also provide Internship on all mentioned courses
ava Introduction - What is Java? Where is Java being Used? types of Java applications, facts about Java, different editions of Java technology, what you will need to run Java and about popular Java Editors.
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...Edureka!
(**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****)
This Edureka tutorial on “Java Threads” will talk about one of the core concepts of Java i.e Java Threads. It will give you a complete insight into how to create, work and synchronize with multiple threads. Through this tutorial you will learn the following topics:
What is a Java Thread?
Thread Lifecycle
Creating a Thread
Main Thread
Multi-Threading
Thread Pool
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Lecture 11 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Describes goods and bads of software architecture as well as common design patterns.
Core Java introduction | Basics | free course Kernel Training
http://kerneltraining.com/core-java/
Learn the basics of Java and gain practical experience that is required to begin your career in java programming. Kernel Training has designed classroom and online course to upgrade your knowledge and skills in core Java.
Course Curriculum:
Introduction to Java
JDK and practical applications
Java Basic Data Types and Operators
Programming Constructs, Classes and Methods, constructor and Finalizer
Polymorphism
Inheritance
Method overriding and abstract classes
Packages and Interfaces
Strings and Arrays
Enums
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
16. Threads in Java
Non-Threaded Applications
Threaded Applications
Process based multitasking Vs Thread based multitasking
Thread API in Java
Creating Threads
States of a Thread
Synchronization for threads; static and non-static synchronized methods; blocks; concept of object and class locks
Coordination between threads - wait, notify and notifyAll methods for inter-thread communication
17. Applets
What are applets?
Need for Applets
Different ways of running an applet program
Applet API hierarchy
Life Cycle of an applet
Even Handlers for applets, mouse events, click events
18. Swing GUI
Introduction to AWT
Introduction to Swing GUI
Advantages of Swing over AWT
Swing API
Swing GUI Components
Event Handlers for Swing
Sample Calculator application using Swing GUI and Swing Event handling
19. JDBC
What is JDBC; introduction
JDBC features
JDBC Drivers
Setting up a database and creating a schema
Writing JDBC code to connect to DB
CRUD Operations with JDBC
Statement types in JDBC
Types of Rowset, ResultSet in JDBC
20. Access Modifiers in Java
What are access modifiers?
Default
Protected
Private
Public
Core Java Tutorial. In case you want to get trained in Spring Framework you can refer here:
<a href="https://www.emexotechnologies.com/courses/java-development-training/core-java-training/">Java Training</a>
In this presentation we introduce topic of core java that is required to learn if you want to be good java programmer. i provide all concept in detail.
Learn JAVA tutorial -This Java tutorial is specially prepared for the Beginners who wants to learn Java programming language from the basics. This tutorial is prepared by Easy Web Solutions by PSK Technologies located in Nagpur that provides best training in Java,PHP,Web Development Hardware and Networking and also provide Internship on all mentioned courses
ava Introduction - What is Java? Where is Java being Used? types of Java applications, facts about Java, different editions of Java technology, what you will need to run Java and about popular Java Editors.
Java Threads Tutorial | Multithreading In Java Tutorial | Java Tutorial For B...Edureka!
(**** Java Certification Training: https://www.edureka.co/java-j2ee-soa-training ****)
This Edureka tutorial on “Java Threads” will talk about one of the core concepts of Java i.e Java Threads. It will give you a complete insight into how to create, work and synchronize with multiple threads. Through this tutorial you will learn the following topics:
What is a Java Thread?
Thread Lifecycle
Creating a Thread
Main Thread
Multi-Threading
Thread Pool
Check out our Java Tutorial blog series: https://goo.gl/osrGrS
Check out our complete Youtube playlist here: https://goo.gl/gMFLx3
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
JDBC : Java Database Connectivity
JDBC is used to connect java application with database.
JDBC is an API used to communicate Java application to database in database independent and platform independent manner.
It provides classes and interfaces to connect or communicate Java application with database.
Vision Academy – Training Institute in Pune Hadapsar is a pioneer in training Institutes providing various professional training courses for multiple technologies. Proficient professionals and experts constitute an institute. We are working on technological domains as a centre for education to give a comprehensive and most exceptional learning experience in various technologies. TIP is the Leading Professional Training Institute for SEO, Digital Marketing Courses in Pune. We also offer other IT Training’s like AngularJS, MVC, Python, Salesforce, Data Science, AI, Blockchain Hadoop, RPA (Blue Prism, Automation Anywhere, and UI Path) Informatics, Selenium. Our Specialty is that we provide Hands-on Training for all Courses, and All Trainers at our Institute are from MNC’s.
Vision Academy is a well known Computer Training Institute in Hadapsar Pune from 2005.This institute was started by its visionary director Mr Sachin Zurange. Mr Sachin Zurange was completed MSc(Scientific Computing) From Interdisciplinary School Of Scientific Computing, University of Pune. It also clear SET exam in May 2018. We provides BCS, BCA, BBA(Comp.App), MCS, MCA, Dip(Comp), BE(Comp/IT) Coaching Classes in Hadapsar Pune.
Lecture 10 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Interactive technical talk for the Agile Saturday VI.
Accompanied with live coding. All code is available on github: https://github.com/angryziber/patterns
Talk from Agile Saturday 3 event in Estonia.
It is about being professional in general as well as following agile best practices, such as build automation and continuous integration.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
2. JDBC
●
Java DataBase Connectivity
– The API for DB access from Java
– Oriented towards relational databases
– java.sql package
– JDBC is DB vendor neutral
● Versions
– Exists since Java 1.1
– Java 1.4 & 1.5 ships with JDBC 3
– Java 1.6 introduced JDBC 4
Java course - IAG0040 Lecture 13
Anton Keks Slide 2
3. JDBC drivers
●
java.sql.Driver - the driver side of the JDBC
layer is the part that interfaces with the
actual database, and therefore is generally
written by database vendors
●
Most developers only need to know how to
install and use drivers. The JDBC Driver API
defines a set of interfaces which have to be
implemented by a vendor
Java course - IAG0040 Lecture 13
Anton Keks Slide 3
4. JDBC driver types
●
Type 1 use a bridge technology to connect a Java client to
ODBC system. The JDBC-ODBC bridge from Sun is one example
of a Type 1 driver
● Type 2 use native code library to access a database, wrapping
a thin layer of Java around the native library, e.g. Oracle OCI
driver
● Type 3 drivers define a generic network protocol that
interfaces with a piece of custom middleware. The
middleware component might use any other type of driver to
provide the actual database access.
● Type 4 drivers are implemented entirely in Java. They
understand database-specific networking protocols and can
access the database directly without any additional software.
Java course - IAG0040 Lecture 13
Anton Keks Slide 4
5. JDBC driver summary
Type 1 ODBC
ODBC bridge diver
Type 2 Native API
Native API
Type 3 Middleware
DB
Network server
Type 4
Pure Java
Java course - IAG0040 Lecture 13
Anton Keks Slide 5
6. JDBC API basics
ResultSet
Statement PreparedStatement CallableStatement
Connection
Application
DriverManager
Oracle, MySQL,
Concrete Driver PostgreSQL,
HSQLDB, etc
Concrete DB
Java course - IAG0040 Lecture 13
Anton Keks Slide 6
7. JDBC basic usage
●
Load the driver (was needed before JDBC 4)
– Class.forName(“driverClassName”);
– System property -Djdbc.drivers=driverClassName
●
Use DriverManager to create connection
– DriverManager.getConnection(url, user, password);
●
Create statement for execution
– connection.createStatement();
●
Execute the query and get a ResultSet
– statement.executeQuery(sql);
● Iterate over ResultSet: rs.next() and rs.getXXX()
● Free resources with close() methods
Java course - IAG0040 Lecture 13
Anton Keks Slide 7
8. Connection
●
java.sql.Connection
● Represents an open connection to the DB
● Obtained via a DriverManager
– DriverManager.getConnection(url, user, password)
●
URL starts with jdbc:
– The exact format depends on the vendor
– jdbc:mysql://server:port/dbname
– jdbc:hsqldb:mem:dbname
– jdbc:oracle:thin:@server:port:sid
Java course - IAG0040 Lecture 13
Anton Keks Slide 8
9. Statement & PreparedStatement
●
java.sql.Statement
– for execution of simple statements without
parameters
– s = conn.createStatement();
s.execute(“CREATE TABLE ..”);
●
java.sql.PreparedStatement
– for execution of parametrized statements via
'parameter binding'
– s = conn.prepareStatement(“SELECT .. WHERE ID = ?”)
s.setInt(1, value); ResultSet rs = s.executeQuery();
– allows for reuse of pre-compiled statements
Java course - IAG0040 Lecture 13
Anton Keks Slide 9
10. ResultSet
●
java.sql.ResultSet
– represents result of a SQL query, containing
multiple rows, similar to an Iterator
– ResultSet rs = s.executeQuery(“SELECT ...”);
while (rs.next()) {
rs.getString(1); or rs.getString(“COLUMN”);
}
rs.close();
– cursor movement by default is
ResultSet.TYPE_FORWARD_ONLY
● Some drivers may support bidirectional
movement
Java course - IAG0040 Lecture 13
Anton Keks Slide 10
11. CallableStatement
●
java.sql.CallableStatement
– extends PreparedStatement
– intended for calling stored procedures in the DB
– allows reading of OUT parameters instead of
getting a ResultSet
– s = conn.prepareCall(“{call SOME_PROC(?, ?, ?)}”);
s.setString(1, “some value”);
s.registerOutParameter(2, Types.VARCHAR);
s.registerOutParameter(3, Types.NUMERIC);
s.execute();
String result1 = s.getString(2);
int result2 = s.getInt(3);
Java course - IAG0040 Lecture 13
Anton Keks Slide 11
12. Resourse Management
●
All DB objects have the close() method
– higher-level DB objects automatically close the
lower-level ones
– conn.close() will close all underlying statements
● Don't forget proper closing
– same pattern applies as with java.io
– it is a good idea to put close() into a finally block!
Java course - IAG0040 Lecture 13
Anton Keks Slide 12
13. Metadata
●
DatabaseMetaData, ResultSetMetaData,
ParameterMetaData
– Metadata provides additional information about
the respective DB objects
– Can be used for discovering of DB structure and
other 'advanced' or non-standard code
– DatabaseMetaData metadata = conn.getMetaData();
String name = metadata.getDatabaseProductName();
– ResultSet rs = s.executeQuery(“SELECT ...”);
ResultSetMetaData metadata = rs.getMetaData();
int columns = metadata.getColumnCount();
Java course - IAG0040 Lecture 13
Anton Keks Slide 13
14. Transactions
●
Connection auto-commit is ON by default
– Use conn.setAutoCommit(false) to control
transactions manually
●
Transaction control
– connection.commit() persists the changes
– connection.rollback() cancels the changes
– connection.setSavepoint() bookmarks transactions
– exact behaviour depends on the concrete DB
Java course - IAG0040 Lecture 13
Anton Keks Slide 14
15. DataSource
●
java.sql.DataSource
– a bean-style alternative to DriverManager
– implemented by a DB vendor
● Is usually initialized in a vendor-specific way in
the application container
– provides getConnection() method
● Spring Framework and Commons-DBCP have
useful implementations, e.g. for connection
pooling
Java course - IAG0040 Lecture 13
Anton Keks Slide 15
16. Data Access Patterns
●
Define where to put the JDBC-related code in
an application
● In general:
– Isolate and encapsulate JDBC code
– Very few classes should know where the data
comes from
– Pass data around as domain objects, not ResultSets
or a mix of Strings or primitive types
Java course - IAG0040 Lecture 13
Anton Keks Slide 16
17. Active Domain Object Pattern
●
aka ActiveRecord
● Wraps a row in a table or view, encapsulates
DB access, and adds domain logic
– JDBC only used internally, not visible from the
outside
– Person person = Person.create();
person.setName(“John Doe”);
person.save();
– Person person = Person.load(“John Doe”);
Java course - IAG0040 Lecture 13
Anton Keks Slide 17
18. Data Accessor Pattern
●
aka Data Access Object (DAO)
● Encapsulates physical data access in a single
component, exposing logical operations
– Application code maintains knowledge about the
underlying data model, but is decoupled from the
data access possibilities
– Domain objects know nothing about the DB
– PersonAccessor dao = new JDBCPersonAccessor();
Person person = dao.loadPerson(“John Doe”);
person.setName(“John Smith”);
dao.save(person);
Java course - IAG0040 Lecture 13
Anton Keks Slide 18
19. Testing
●
Clear separation of DB access logic from
business logic makes testing and maintenance
a lot easier
●
All JDBC interfaces can be easily mocked
– Connection conn = createMock(Connection.class);
●
Sometimes it is wise to test the full-cycle
– Use in-memory database, e.g. HSQLDB
– Initialize the data there and substitute DB
connection with the fake in-memory one
– DBUnit can help with that
Java course - IAG0040 Lecture 13
Anton Keks Slide 19
20. Logging
● When writing more complex applications, you need logging in
your code
– you don't want to show low-level crash info to end-users
– debugging of bugs on production is usually not possible
● There are many possibilities to implement logging:
– System.out / System.err or other java.io classes – usually
primitive and not flexible solution
– java.util.logging, e.g. Logger class – logging API included in Java
since 1.4, configurable and extensible
– Log4J – very popular de-facto standard framework, very
powerful, has a very good API
– Jakarta commons-logging – the facade for different logging APIs
Java course - IAG0040 Lecture 13
Anton Keks Slide 20
21. java.util.logging
● Logger LOG = Logger.getLogger(this.getClass().getName());
– Loggers have hierarchical structure ('.' separated), it is a good idea to use
full class name as a logger name
– Logger often used as a static member (for convenience)
● Loggers can be used for logging information with various levels
– SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST
– LOG.severe(“We have a problem!”);
– LOG.log(Level.SEVERE, “We have a problem”, exception);
● java.util.logging is configurable
– by default it uses $JAVA_HOME/jre/lib/logging.properties
– specific file is specified with sys. property java.util.logging.config.file
Java course - IAG0040 Lecture 13
Anton Keks Slide 21
22. java.util.logging (cont)
● Logger is used to produce LogRecords
– every LogRecord has a specified logging Level
– every Logger may have its own Level assigned
– or they inherit Level from their parent
● LogRecords are passed to one or more Handlers
– e.g. ConsoleHandler, FileHandler, MemoryHandler, SocketHandler, etc
– every handler writes logs greater or equal to their assigned Level
● Formatters are used for formatting of LogRecords
– SimpleFormatter or XMLFormatter
● a LogRecord is written only if its Level is greater than of its Logger's and if
there is a Handler configured to write at this Level
● Filters may be used for more fine-grained control of what should be logged
Java course - IAG0040 Lecture 13
Anton Keks Slide 22
23. Log4J (org.apache.log4j)
● Logger LOG = Logger.getLogger(this.getClass());
– Loggers have hierarchical structure ('.' separated), same as util.logging
● Loggers can be used for logging information with various levels
– FATAL, ERROR, WARN, INFO, DEBUG are default levels
– LOG.error(“We have a problem!”, exception);
● Log4J is fully configurable with external files
– there is no default configuration
– it automatically looks for log4j.xml or log4j.properties in classpath
– can be overriden with log4j.configuration system property
– every named logger can have its own configuration
– different appenders can be used for writing the actual data
Java course - IAG0040 Lecture 13
Anton Keks Slide 23