├── README.md
└── src
└── net
└── javaguides
└── jdbc
├── CountDuplicateCharacters.java
├── CountVowelsAndConsonants.java
├── FirstNonRepeatedCharacter.java
├── JdbcAutoGenKey.java
├── JdbcMySQLVersion.java
├── JdbcReadImage.java
├── JdbcWriteImage.java
├── RemoveGivenCharacter.java
├── crud
├── CreateStatementExample.java
├── InsertPStatementExample.java
├── JDBCUtils.java
├── SelectPStatementExample.java
└── UpdatePStatementExample.java
├── h2
└── crud
│ ├── H2CreateExample.java
│ ├── H2DeleteExample.java
│ ├── H2InsertExample.java
│ ├── H2JDBCUtils.java
│ ├── H2SelectExample.java
│ └── H2UpdateExample.java
└── hsqldb
└── crud
├── HSQLDBCreateExample.java
├── HSQLDBDeleteExample.java
├── HSQLDBInsertExample.java
├── HSQLDBSelectExample.java
├── HSQLDBUpdateExample.java
└── JDBCUtils.java
/README.md:
--------------------------------------------------------------------------------
1 | # JDBC-4.2-Tutorial
2 | JDBC 4.2 Tutorial with Java 8
3 |
4 |
5 |
6 |
7 | This is complete beginners to expert up-to-date
JDBC 4.2 Tutorial. In this tutorial, we will learn the latest features added to JDBC 4,4.1 and 4.2 release. All the source code examples in this tutorial are developed using JDK 8 with JDBC 4.2.
8 |
9 | JDBC stands for Java Database Connectivity, which is a standard Java API for database-independent connectivity between the Java programming language and a wide range of databases.
10 |
11 |
Java JDBC API Overview
12 |
13 | JDBC 4.2 API - Statement
14 |
17 | Example to update a record in a table using Statement interface.
18 |
21 | Example to insert multiple records in a table using Statement interface.
22 |
25 | Example to create a table using Statement interface.
26 |
29 | Example to retrieve records from a table using Statement interface.
30 |
33 | Example to delete a record from a table using Statement interface.
34 |
37 | Example to insert records in a batch process via Statement interface.
38 |
41 | Example to update records in a batch process via Statement interface.
42 |
43 | JDBC 4.2 API - PreparedStatement
44 |
47 | Example to insert a record in a table using PreparedStatement interface.
48 |
51 | Example to update a record in a table using PreparedStatement interface.
52 |
55 | Example to retrieve records from a table using PreparedStatement interface.
56 |
59 | Example to pass a list of values to IN clause using PreparedStatement interface.
60 |
63 | Example to insert records in a batch process via PreparedStatement interface.
64 |
67 | Example to update records in a batch process via PreparedStatement interface.
68 |
69 | JDBC 4.2 API - CallableStatement
70 |
73 | Create and use Stored Procedure examples using CallableStatement interface.
74 |
75 | JDBC 4.2 API - Transactions
76 |
79 | How to use JDBC transactions with examples.
80 |
81 | JDBC 4.2 API - SQLExceptions Handling
82 |
85 |
86 | In this article, we will learn how to handle SQLExceptions while working with JDBC.
87 |
88 | JDBC 4.2 API - java.sql Package
89 |
92 |
93 | In this article, we will learn commonly used methods of Connection interface with examples.
94 |
97 | In this article, we will learn commonly used methods of Statement interface with examples.
98 |
101 | In this article, we will learn commonly used methods of PreparedStatement interface.
102 |
105 | In this article, we will learn commonly used methods of CallableStatement interface.
106 |
109 | In this article, we will learn commonly used methods of ResultSet interface with examples.
110 |
113 | In this article, we will learn commonly used methods of ResultSetMetaData interface.
114 |
117 | In this article, we will learn commonly used methods of DatabaseMetadata interface.
118 |
121 | In this article, we will learn commonly used methods of DriverManager class with examples.
122 |
123 | JDBC 4.2 API - Batch Processing
124 |
127 | Example to update records in a batch process using Statement and PreparedStatement interfaces.
128 |
131 | Example to insert records in a batch process using Statement and PreparedStatement interfaces.
132 |
135 | Example to insert records in a batch process via Statement interface.
136 |
139 | Example to update records in a batch process via Statement interface.
140 |
143 | Example to insert records in a batch process via PreparedStatement interface.
144 |
147 | Example to update records in a batch process via PreparedStatement interface.
148 |
149 | JDBC 4.2 API FAQ
150 |
153 | Example to dynamically insert rows using StringBuilder and PreparedStatement placeholders ?.
154 |
157 | This article provides how to retrieve column names of a table using getMetaData() method.
158 |
161 | Example of how to use DataSource to connect with MySQL database.
162 |
163 | Resource and Useful Links
164 |
165 |
166 |
167 |
170 |
173 |
176 |
179 |
182 |
185 |
188 |
191 |
194 |
197 |
200 |
201 |
202 |
205 |
208 |
209 |
210 |
211 | Reference
212 |
219 |
220 |
221 |
222 |
--------------------------------------------------------------------------------
/src/net/javaguides/jdbc/CountDuplicateCharacters.java:
--------------------------------------------------------------------------------
1 | package net.javaguides.jdbc;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collections;
5 | import java.util.HashMap;
6 | import java.util.Map;
7 | import java.util.stream.Collectors;
8 |
9 | public class CountDuplicateCharacters {
10 | private static final String TEXT = "Java is a popular "
11 | + " general-purpose programming language "
12 | + "and computing platform. It is fast, reliable, and secure.";
13 |
14 | public static void main(String[] args) {
15 |
16 | System.out.println("Input text: \n" + TEXT + "\n");
17 |
18 | System.out.println("HashMap based solution:");
19 | Map