View RSS Feed

All Blog Entries

  1. Simple Frame Transitions without Complex Code

    by , 03-22-2012 at 08:18 PM
    I've spent the past few days looking up Java window transitions that work with Swing components & containers (JFrame, JPanel, etc.).

    Yes, there are packages such as JavaFX which includes a Timeline & Transition framework. I also came across these:

    Project Kenai — We're More Than Just a Forge

    Filthy Rich Clients (find the Animation jar (org.jdesktop.animation))

    However, I've been impatient lately ...
  2. Executing PreparedStatement Objects

    by , 03-10-2012 at 09:03 AM
    • Execute statement shall be called for execution of a PreparedStatement Object.
    • The executeQuery when just 1 ResultSet is returned by query,
    • The executeUpdate when no ResultSet is returned by query.
    • The execute when one or more than one ResultSet object return by query.

    Call of “execute update” method is explained by this code.
    Java Code:
    updateSales.setInt(1, e.getValue().intValue());
    updateSales.setString(2, e.getKey());
  3. Categorized SQLExceptions

    by , 03-10-2012 at 09:01 AM
    JDBC driver shall throw SQLException subclass, which presents a common error state or common SQLState. They are not linked to any specified SQLState calss value.

    Portable error handling codes are written by its help.

    These exceptions given are the sub-classes of 1 of the given classes.

    • SQLNonTransientException
    • SQLRecoverableException
    • SQLTransientException
  4. Retrieving Warnings

    by , 03-10-2012 at 09:00 AM
    The SQLWarning objects are subclasses of SQLException. They are involved in dealings with database access warnings. Warning actually doesn’t stop the execution of program, as oppose to exceptions. They inform users that few things which are not present in execution plan are happening.

    • A privilege revoked didn’t revoke.
    • An error occurred, during the requested disconnections.

    A warning might be on:
    • A connection object
    • A ResultSet object
    • A
  5. Retrieving Exceptions

    by , 03-10-2012 at 08:58 AM
    The given code outputs the following that is contained in the SQLException or other exception which have been chained to it:
    • SQL State
    • Error description
    • Error Code
    • Cause

    Java Code:
    public static void
        printSQLException(SQLException ex) {
        for (Throwable e : ex) {
            if (e instanceof SQLException) {
                if (ignoreSQLException(
                    getSQLState()) == false)
  6. Overview of SQLException

    by , 03-10-2012 at 08:57 AM
    Opposed to Exception, SQL Exception’s instance is thrown when an error occurs with JDBC while doing communication with data source. Data source is the database presentation to which connection is been made to an application.

    Error’s root cause is determined by the useful information that is given in SQLException.

    • An error’s description: Method SQLException.getMessage() returns the string, which details the error.
    • A SQL state code. Codes are ISO/ANSI standardized.
    Tags: sqlexception Add / Edit Tags
  7. Advantages of DataSource Objects

    by , 03-10-2012 at 08:56 AM
    A DataSource object is considered a good alternative of class “DriverManager” and is most preferable to be used as it creates a database connection. There is no need to hard code the JDBC URL or driver name in application while using DataSource object. Such approach is loosely coupled & more portable.

    When there is a need to do alterations then changes might be done in properties file by the admin and no code changes of ever application is needed, which is involved in its implementation. ...
  8. Using DataSource Objects to Get a Connection

    by , 03-10-2012 at 08:54 AM
    Classes instantiate object which implement Datasource. This presents particular some data source like a file, or DBMS.

    A particular DBMS is presented by a DataSource object. For more than 1 data source usage, it is required to have separate DataSource objects for every data source. There are 3 ways for implementation of the DataSource interface.

    • Standard Connection objects are produced by the implementation of basic DataSource. These objects are not used or pooled
  9. MySQL Connector/J Database URL

    by , 03-10-2012 at 08:52 AM
    For MySQL Connector/J, the database connection URL syntax is given below:


    • host: Port is host’s name & port no. of that computer which host database. Port and host default values are 3306 and , if not specified,
    • database is database name to connect. Without default database connection is
  10. MySQL Connector/J Database URL

    by , 03-10-2012 at 08:51 AM
    For MySQL Connector/J, the database connection URL syntax is given below:


    • host: Port is host’s name & port no. of that computer which host database. Port and host default values are 3306 and , if not specified,
    • database is database name to connect. Without default database connection is

    Updated 03-10-2012 at 08:53 AM by Java Database

  11. Java DB Database Connection URLs

    by , 03-10-2012 at 08:49 AM
    For Java DB, here is the given database connection URL syntax:


    • subsubprotocol makes Java DB specific to search in class path, database, directory, memory or in JAR file. Typically it is omitted.
    • databaseName is the database name to connect.
    • attribute=value presents semicolon-separated optional attributes list. Such attributes make you able to give instructions to Java DB so that to perform
  12. Using the DriverManager Class

    by , 03-10-2012 at 08:47 AM
    The “DriverManager” class provides a method “DriverManager.getConnection” that is called when connection to your DBMS. The following code explains the use of getConnection method.
    Java Code:
    public Connection getConnection()
        throws SQLException {
        Connection conn = null;
        Properties connectionProps = new Properties();
        connectionProps.put("user", this.userName);
        connectionProps.put("password", this.password);
  13. Establishing a Connection

    by , 03-10-2012 at 08:44 AM
    The very 1st step to use data source is to make connection with data source. Data source could be:
    • Legacy file system
    • DBMS
    • Few other data sources, with a corresponding JDBC driver

    For connecting an application to data source, these 2 classes are used.

    • DriverManager: Complete implementation is provided by this class so that to make a connection b/w application and a data source, that is specified by URL of database. JDBC drivers are automatically loaded
  14. Closing Connections

    by , 03-10-2012 at 08:43 AM
    Method Statement.close shall always be called to release resources instantly that are in use when usage of a statement gets finished. To close ResultSet object, call Statement.close method.

    For closing all resources or release the memory present in Java program, finally block is used.

    Given piece of code details how a statement is closed in the finally block present in your program.
    Java Code:
    } finally {
        if (stmt != null) { stmt.close(); }
  15. Processing ResultSet Objects

    by , 03-10-2012 at 08:42 AM
    Data that has been store in a ResultSet is accessed by a cursor. In ResultSet object, one row of data is pointed by the help of this cursor. In beginning, before 1st row the pointer gets positioned. Different methods are provided by the ResultSet objects so that to move the cursor.

    Given code details the ResultSet object processing.
    Java Code:
    try {
        stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while ( {
  16. Executing Queries

    by , 03-10-2012 at 08:40 AM
    Execute method is called from statement for execution of a query.
    • execute: In case when 1st object which query returns is ResultSet, returns true. This method is used when one or more than one ResultSet objects are returned by query. ResultSet objects are retrieved that have been returned from query, by calling Statement.getResultSet repeatedly.
    • executeQuery: One ResultSet object is retuned.
    • executeUpdate: An integer is returned which presents the rows that have been affected by SQL
  17. Creating Statements

    by , 03-10-2012 at 08:39 AM
    A Statement interface presents a SQL statement. Generations of the ResultSet objects take place in response of the execute Statement objects. ResultSet is a data table which presents the database result set.
    To make Statement object, a connection object is needed. To create statement, consider this code:
    Stmt = con.createStatement();

    The following are the three different kinds of statements.
    • Statement: Simple SQL statements are implemented by it without any
  18. JDBC Product Components

    by , 03-10-2012 at 08:38 AM
    Following four components are included in JDBC:
    • The JDBC API: From Java programming languages, access is provided to relational databases by JDBC API. Following could be performed by JDBC API.

    o Retrieves the results
    o Execution of SQL Statements
    o Propagate alterations back to the data sources
    o Interaction with various data sources, in a distributed environment.

    • JDBC Driver Manager: DriverManager class of JDBC provides connections b/w JDBC
  19. JDBC Introduction

    by , 03-10-2012 at 08:36 AM
    JDBC API being a java base API, it accesses stored data and tabular data present in relational database. Java applications are written by the help of JDBC API. They are helpful to manage these programming activities, given below:
    • To a data source, connect like a database
    • Send updated statements & database queries.
    • Bring records of database & do processing of these records that have been received from the database.

    The given code details the above 3 steps. ...
  20. JDBC drivers

    by , 03-10-2012 at 08:35 AM
    Kinds of drivers provided by JDBC are also known as client side adapters. At the client’s machines, such drivers are installed. Request conversions from Java programs into protocol are done by them which are understandable by DBMS.

    Commercial as well as free drivers are present for most of the databases so that they could be used along with the Java programs. Such drivers come in these given categories.

    • Type 1: Native code of ODBC driver which is locally available
    Tags: jdbc drivers Add / Edit Tags
  21. JDBC Functionality

    by , 03-10-2012 at 08:33 AM
    Various implementations are there for JDBC that are used by same application. Mechanism is provided by API:
    • Dynamically correct Java packages are loaded
    • Registration with the JDBC Driver Manager

    JDBC driver manager, being a connection factory is used for creation of JDBC connections.

    Following is supported by JDBC connections:
    • Creating statements
    • Update statements
    • Executing statements
    • Stored procedure is invoked by using the JDBC Connection.
  22. JDBC Key Features

    by , 03-10-2012 at 08:30 AM
    Key features of the JDBC API are:
    • Full Access to Metadata: Sophisticated application development is enabled by JDBC API, by providing metadata access. Underlying facilities and database connections capabilities are required to be understood by using metadata.
    • No Installation: No installation is needed along with usage of pure JDBC technology
    • Database Connection Identified by URL: Internet standard URLs advantage is exploited by JDBC technology to identify database connection. Data
  23. Multiple variables

    by , 03-10-2012 at 12:44 AM
    I'm just getting started with programming and i want it so that if the variable = 0 it doesn't show up in the equation. I made an alternate boolean variable but i need help with the rest or any other ideas

    public class App {

    public App() {
    public static void main(String[] args) {

    float speed = 2;
    boolean speed2;
    if (speed >= 0){speed2 = true;
    }else ...
  24. Advantages of JDBC Technology

    by , 03-09-2012 at 08:35 PM
    JDBC Technology offers these given advantages.

    Leverage Existing Enterprise Data: Businesses or users are not been locked to a particular architecture. Installed databases can be used with JDBC technology to access information with ease. Even if they are stored at other databases, even then they have access for usage.

    Simplified Enterprise Development: Development of application has become an easier task which is also cost effective along with JDBC API & Java API. ...
  25. JDBC Architecture

    by , 03-09-2012 at 08:33 PM
    The JDBC API consist of these 2 major interfaces sets:
    • JDBC API, for application writers
    • JDBC driver API, for driver writers

    JDBC drivers fall in 1 of the four given categories. Given figure shows that applets & applications access databases through JDBC API, by using pure Java JDBC driver.

    Name:  1.JPG
Views: 2839
Size:  11.5 KB
    JDBC Architecture

    JDBC calls are converted by such kind of drivers to network protocol. This allows client machines ...
  26. The Java Database Connectivity (JDBC)

    by , 03-09-2012 at 08:31 PM
    Java Database Connectivity JDBC API is considered to be a database’s industry standard. An independent connectivity is provided by it b/w range of databases and Java programming language. Like
    • Tabular data sources e.g. flat files and spreadsheet.
    • SQL databases

    To access SQL based database, call level API is provided by JDBC API.

    In Java programming language, JDBC technology is used to “write once, Run Anywhere” capabilities. This is done for those applications ...
    Tags: jdbc Add / Edit Tags
  27. SQL Metadata

    by , 03-09-2012 at 08:30 PM
    Users and database information is stored itself in databases. Majority of DBMS consist of s set of system tables, which lists:
    • Tables in the database
    • Primary keys
    • Foreign keys
    • Column names in each table
    • Stored procedures

    Database features and table layout information is obtained by DBMS which consists of its own functions. Interface DatabaseMetaData is provided by the JDBC that shall be implemented by a driver writer. This is done information regarding DBMS ...
    Tags: sql metadata Add / Edit Tags
  28. SQL Transactions

    by , 03-09-2012 at 08:29 PM
    In a database, at the same time two users might be accessing the similar data. E.g if one user is reading column’s value from database and other one is updating column at the same time. This is possible that 1st user may get old & update data, at the same time.
    To prevent these situations, transactions are provided by DBMS so that to maintain data in persistent state. More than 1 user may access database with data concurrency, at the same time.

    More than 1 SQL statements ...
  29. Result Sets and Cursors

    by , 03-09-2012 at 08:28 PM
    Conditions of a query are satisfied by the result set. Result set is considered to be rows set. A result set can return no. of rows.
    • Zero
    • One
    • Many

    One user might obtain 1 row at one time. This functionality is supported by the cursor.
    Pointer and cursor are same which are present in a file that consists of many rows of the result set. Rows track is maintained by the pointer, which are accessible by the program. All rows top to bottom access is supported by a cursor, ...
  30. SELECT Statements

    by , 03-09-2012 at 08:27 PM
    SQL is considered to be a query language which has been designed for using it with relational databases. Standard SQL commands set is present which is used along with all relational DMS i.e. database management system. All relational DBMS use select statement.

    Information is obtained from a table by select statement. This is also known as a query. Following is specified by it.
    • 1 or more columns
    • Selection criteria
    • 1 or more tables

    First & last names ...
Page 15 of 48 FirstFirst ... 5131415161725 ... LastLast