JDBC / NOTES</>↗JDBC30 Dec 2007
This example shows you how to read BLOBs data from database table. package org.kodejava.jdbc; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.sql.*; public class BlobReadDemo { private static final String URL = "jdbc:mysql://localhost/kodejava"; private static final String USERNAME = "kodejava"; private static final String PASSWORD = "s3cr*t"; public static void main(String[] args) { […]
JDBC / NOTES</>↗JDBC26 Dec 2007
Database BLOBs (Binary Large Objects) can be used to store any data, such as images, audio, or video files, for instance. This example shows you how we use JDBC library to store image in our database. To send the binary information to the database, we can call the PreparedStatement.setBinaryStream() method and pass the appropriate input […]
JDBC / NOTES</>↗JDBC25 Dec 2007
Stored-procedure are user-generated functions or procedures that, once created in the database, it can be called by the client applications, such as Java application. In this example we’ll demonstrate how to use the JDBC java.sql.CallableStatement to call a stored procedure. The store procedure in this example is just for selecting records from the products table. […]
CORE API / NOTES</>↗Core API21 Dec 2007
The trick to sort a java.util.Set is to use the implementation of a java.util.SortedSet such as the java.util.TreeSet class. The example below shows you the result of using the java.util.TreeSet class, in which the items in it will be sorted based on the element’s natural order. package org.kodejava.util; import java.util.Set; import java.util.TreeSet; public class TreeSetDemo […]
REGEX / NOTES</>↗Regex17 Dec 2007
In this example you’ll see how we can create a small search and replace program using the regular expression classes in Java. The code below will replace all the brown words to red. package org.kodejava.regex; import java.util.regex.Pattern; import java.util.regex.Matcher; public class StringReplace { public static void main(String[] args) { String source = "The quick brown […]
REGEX / NOTES</>↗Regex14 Dec 2007
This example demonstrates how we do regular expression in Java. The regular expression classes is in the java.uti.regex package. The main class including the java.util.regex.Pattern class and the java.util.regex.Matcher class. In this example we are only testing to match a string literal if it is exists in the following sentence, we are searching the word […]