View RSS Feed

All Blog Entries

  1. Using DataSource Objects to Get a Connection

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  2. MySQL Connector/J Database URL

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

    jdbc:mysql://[host][,failoverhost...]
    [:port]/[database]
    [?propertyName1][=propertyValue1]
    [&propertyName2][=propertyValue2]...

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

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

    jdbc:mysql://[host][,failoverhost...]
    [:port]/[database]
    [?propertyName1][=propertyValue1]
    [&propertyName2][=propertyValue2]...

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

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

    Categories
    JDBC
  4. Java DB Database Connection URLs

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

    jdbc:derby:[subsubprotocol:][databaseName]
    [;attribute=value]*

    • 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
    ...
    Categories
    JDBC
  5. Using the DriverManager Class

    by , 03-10-2012 at 07: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);
    ...
    Categories
    JDBC
  6. Establishing a Connection

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  7. Closing Connections

    by , 03-10-2012 at 07: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(); }
    }
    ...
    Categories
    JDBC
  8. Processing ResultSet Objects

    by , 03-10-2012 at 07: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 (rs.next()) {
    ...
    Categories
    JDBC
  9. Executing Queries

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  10. Creating Statements

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  11. JDBC Product Components

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  12. JDBC Introduction

    by , 03-10-2012 at 07: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. ...
    Categories
    JDBC
  13. JDBC drivers

    by , 03-10-2012 at 07: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
    Categories
    JDBC
  14. JDBC Functionality

    by , 03-10-2012 at 07: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.
    ...
    Categories
    JDBC
  15. JDBC Key Features

    by , 03-10-2012 at 07: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
    ...
    Categories
    JDBC
  16. Multiple variables

    by , 03-09-2012 at 11:44 PM
    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) {


    System.out.println("Skating");
    float speed = 2;
    boolean speed2;
    if (speed >= 0){speed2 = true;
    }else ...
    Categories
    Uncategorized
  17. Advantages of JDBC Technology

    by , 03-09-2012 at 07: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. ...
    Categories
    JDBC
  18. JDBC Architecture

    by , 03-09-2012 at 07: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: 1793
Size:  11.5 KB
    JDBC Architecture

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

    by , 03-09-2012 at 07: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
    Categories
    JDBC
  20. SQL Metadata

    by , 03-09-2012 at 07: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
    Categories
    SQL
  21. SQL Transactions

    by , 03-09-2012 at 07: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 ...
    Categories
    SQL
  22. Result Sets and Cursors

    by , 03-09-2012 at 07: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, ...
    Categories
    SQL
  23. SELECT Statements

    by , 03-09-2012 at 07: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 ...
    Categories
    SQL
  24. Integrity Rules

    by , 03-09-2012 at 07:26 PM
    It shall be ensured by the relational tables that data is always accessible and accurate. To do this, implementation of the integrity rules is required. These rules shall be followed.
    • There shall be uniqueness in a table’s rows.
    • Correct results are not found easily and accessing data might result into certain issues. This happens when duplicate rows are present.


    Rules can be applied by user in most DBMS that duplicated rows are not permitted. In those cases, the insertion ...
    Categories
    SQL
  25. What Can SQL do?

    by , 03-09-2012 at 07:25 PM
    • Against a database, queries can be executed by SQL.
    • From a database, data can be retrieved by SQL.
    • In a database, records can be inserted by SQL.
    • In a database, records can be updated by SQL.
    • From a database, records can be deleted by SQL.
    • New databases are created by SQL.
    • In a database, new tables are created by SQL.
    • In a database, stored procedures can be created by SQL.
    • In a database, views are created by SQL.
    • SQL can set permissions at procedures, views and tables.
    Categories
    SQL
  26. Sql

    by , 03-09-2012 at 07:21 PM
    Databases are accessed by usage of a standard language SQL. It is used for the manipulation and also to access the data, in following.
    • MySQL
    • DB2
    • Access
    • Oracle
    • SQL Server
    • Sybase


    The SQL language consist of these language elements:

    • Clauses: Clauses are considered to be the constituent components of queries and statements.
    • Expressions: They can produce tabular data or scalar values which comprises of columns & rows.
    • Predicates: conditions
    ...
    Tags: sql Add / Edit Tags
    Categories
    SQL
  27. Builder Pattern - Specific problems and implementation

    by , 03-09-2012 at 07:16 PM
    Builder & the Abstract Factory

    Builder design pattern and the abstract Factory pattern have a lot of similar things. This is the reason why it is necessary to come up with certain different condition b/w situations, when we use one of them. For abstract factory, factory methods are used by the client so that to make its own objects. In case of builder, the builder class gets instructions regarding the way to create object. However in which way the class will be put together depends ...
  28. Builder Pattern - Applicability & Examples

    by , 03-09-2012 at 07:15 PM
    Builder pattern could be used when:
    • Creation algorithms of complexed objects are not dependent upon parts that compose the objects.
    • System allows the representation of many different objects.


    Vehicle Manufacturer

    Consider an example of vehicle manufacture that creates bicycle, a car, a scooter and a motorcycle. In such case, builder would be the Vehicle Builder. Interface is being specified to build any kind of vehicle in the above list by using similar ...
  29. Builder Pattern - Implementation

    by , 03-09-2012 at 07:13 PM
    Factory builder pattern is used by the builder design patter so that to make a decision which concrete class for initiation to build the desired object type.

    In this pattern, the participant classes are:
    • An abstract interface is specified by the builder class to create the product object parts.
    • ConcreteBuilder creates and puts the product parts together by doing the implementation of the builder interface. It also keeps the proper representation track that has been created
    ...
  30. Builder Pattern

    by , 03-09-2012 at 07:12 PM
    Complexity of the objects as well as classes increases along with the complexity of an application. Complex objects basically are manufactured of those parts that are produced by the various other objects which require special attention while building. A proper mechanism is needed by the application to build the complex objects, independent of those that build object. If you are also facing the same problems then try to use the Builder design pattern.

    Such patterns permit the client ...
    Categories
    Builder Pattern
Page 15 of 48 FirstFirst ... 5131415161725 ... LastLast