Wednesday, September 1, 2010

The Architecture of the Java Virtual Machine

Java Virtual Machine

Java Virtual Machine like its real counter part, executes the program and generate output. To execute any code, JVM utilizes different components.

JVM is divided into several components like the stack, the garbage-collected heap, the registers and the method area. Let us see diagram representation of JVM.

The Stack

Stack in Java virtual machine stores various method arguements as well as the local variables of any method. Stack also keep track of each an every method invocation. This is called Stack Frame. There are three registers thats help in stack manipulation. They are vars, frame, optop. This registers points to different parts of current Stack.

There are three sections in Java stack frame:
Local Variables

The local variables section contains all the local variables being used by the current method invocation. It is pointed to by the vars register.
Execution Environment

The execution environment section is used to maintain the operations of the stack itself. It is pointed to by the frame register.
Operand Stack

The operand stack is used as a work space by bytecode instructions. It is here that the parameters for bytecode instructions are placed, and results of bytecode instructions are found. The top of the operand stack is pointed to by the optop register.
Method Area

This is the area where bytecodes reside. The program counter points to some byte in the method area. It always keep tracks of the current instruction which is being executed (interpreted). After execution of an instruction, the JVM sets the PC to next instruction. Method area is shared among all the threads of a process. Hence if more then one threads are accessing any specific method or any instructions, synchorization is needed. Synchronization in JVM is acheived through Monitors.
Garbage-collected Heap

The Garbage-collected Heap is where the objects in Java programs are stored. Whenever we allocate an object using new operator, the heap comes into picture and memory is allocated from there. Unlike C++, Java does not have free operator to free any previously allocated memory. Java does this automatically using Garbage collection mechanism. Till Java 6.0, mark and sweep algorithm is used as a garbage collection logic. Remember that the local object reference resides on Stack but the actual object resides in Heap only. Also, arrays in Java are objects, hence they also resides in Garbage-collected Heap.

The Architecture of the Java Virtual Machine

In the Java virtual machine specification, the behavior of a virtual machine instance is described in terms of subsystems, memory areas, data types, and instructions. These components describe an abstract inner architecture for the abstract Java virtual machine. The purpose of these components is not so much to dictate an inner architecture for implementations. It is more to provide a way to strictly define the external behavior of implementations. The specification defines the required behavior of any Java virtual machine implementation in terms of these abstract components and their interactions.

Figure 5-1 shows a block diagram of the Java virtual machine that includes the major subsystems and memory areas described in the specification. As mentioned in previous chapters, each Java virtual machine has a class loader subsystem: a mechanism for loading types (classes and interfaces) given fully qualified names. Each Java virtual machine also has an execution engine: a mechanism responsible for executing the instructions contained in the methods of loaded classes.

When a Java virtual machine runs a program, it needs memory to store many things, including bytecodes and other information it extracts from loaded class files, objects the program instantiates, parameters to methods, return values, local variables, and intermediate results of computations. The Java virtual machine organizes the memory it needs to execute a program into several runtime data areas.

Although the same runtime data areas exist in some form in every Java virtual machine implementation, their specification is quite abstract. Many decisions about the structural details of the runtime data areas are left to the designers of individual implementations.

Different implementations of the virtual machine can have very different memory constraints. Some implementations may have a lot of memory in which to work, others may have very little. Some implementations may be able to take advantage of virtual memory, others may not. The abstract nature of the specification of the runtime data areas helps make it easier to implement the Java virtual machine on a wide variety of computers and devices.

Some runtime data areas are shared among all of an application's threads and others are unique to individual threads. Each instance of the Java virtual machine has one method area and one heap. These areas are shared by all threads running inside the virtual machine. When the virtual machine loads a class file, it parses information about a type from the binary data contained in the class file. It places this type information into the method area. As the program runs, the virtual machine places all objects the program instantiates onto the heap. See Figure 5-2 for a graphical depiction of these memory areas.

As each new thread comes into existence, it gets its own pc register (program counter) and Java stack. If the thread is executing a Java method (not a native method), the value of the pc register indicates the next instruction to execute. A thread's Java stack stores the state of Java (not native) method invocations for the thread. The state of a Java method invocation includes its local variables, the parameters with which it was invoked, its return value (if any), and intermediate calculations. The state of native method invocations is stored in an implementation-dependent way in native method stacks, as well as possibly in registers or other implementation-dependent memory areas.

The Java stack is composed of stack frames (or frames). A stack frame contains the state of one Java method invocation. When a thread invokes a method, the Java virtual machine pushes a new frame onto that thread's Java stack. When the method completes, the virtual machine pops and discards the frame for that method.

The Java virtual machine has no registers to hold intermediate data values. The instruction set uses the Java stack for storage of intermediate data values. This approach was taken by Java's designers to keep the Java virtual machine's instruction set compact and to facilitate implementation on architectures with few or irregular general purpose registers. In addition, the stack-based architecture of the Java virtual machine's instruction set facilitates the code optimization work done by just-in-time and dynamic compilers that operate at run-time in some virtual machine implementations.

See Figure 5-3 for a graphical depiction of the memory areas the Java virtual machine creates for each thread. These areas are private to the owning thread. No thread can access the pc register or Java stack of another thread.
READ MORE - The Architecture of the Java Virtual Machine

Java Methods in the Database

Java Methods in the Database

When the database class is created it includes the methods from the original Java class. As a result, SQL commands can include calls to Java methods:

• wherever a value is used - in expressions, select lists, where clauses, etc. (the value of a method call is its return value),
• in the EXECUTE command, as a stored procedure (see Stored Procedures), or
• in the EVALUATE clause of the UPDATE command, to change the state of object columns.

Static method calls can use the form:

[ [ catalog-name . ] schema-name . ] class-name . method-name (...)
class-name must be the database name of a cataloged Java class.
Instance method calls use the form:
( instance-expression ) . method-name (...)

instance-expression is a SQL expression returning an object. It could be:

• a reference to an object column,
• a call to a method returning a database object,
• a NEW clause creating a new database object, or
• the result of a CAST operator casting one of the above expressions to a database class; a ? placeholder can also be cast to a database class.

Note: you can omit the parentheses for a reference to an object column, in most cases.

In the rows of the database table, the value of a column defined with Java class is an instance (object) of the Java class. Instances are created using the constructor for the class. Column values are active instances and their methods are callable in SQL commands. When the client retrieves a column value defined as a Java class, it is an active object that is often executed in the Client's JVM. Both class and instance methods may be accessible.

Stored Procedures in Java

Since the beginning, stored procedure languages have been proprietary to each database vendors, with no commonality. Using more portable languages, like C++, for server procedures has raised issues of safety (an errant procedure could crash the server) and security. Now, with most DB vendors supporting it, Java is becoming the stored procedure language of choice, promising portability and safety.

Stored procedures can be implemented as Java methods. A client application calls a Java stored procedure through JDBC or ODBC using standard syntax. The server translates this syntax into direct calls to user defined Java methods cataloged on the server.

Stored procedures access the database using JDBC and they can return basic values and Java objects. Java objects can include individual JDBC result sets or JDBC statements containing multiple results.
See the FIRSTSQL/J STORED PROCEDURE EXAMPLE at the end of this tutorial

The static methods of a database class are callable as stored procedures:

EXECUTE ? = Money.convert(?, ‘Euro’)

Stored procedures also support output parameters in the form of Java objects. The stored procedure can modify an object passed as a parameter and return the modified object to the caller (the client). The Java object must be derived from a Java class cataloged in the database.

Java servlets are an excellent fit for a Java stored procedure:

• Portability - Java database servlets can be written in pure Java using standard JDBC for database access.
• Safety - Java code is free from pointer misuse and memory leaks. The JVM (Java Virtual Machine) applies the sandbox approach to executing Java code, restricting external access.
• Security - The JVM sandbox mechanism provides secure execution of Java code. The JVM also supports authentication of Java database servlets.

With a portable stored procedure language, code can be transferred between servers and JVMs from different vendors, vendor-specific training is reduced and database-independent applications can be distributed with application-specific stored procedure code.
READ MORE - Java Methods in the Database

Friday, June 18, 2010

example java script in 'plugins' sample length, Mimetype, suffixes, type.

Example java script in 'plugins' sample length, Mimetype, suffixes, type.

READ MORE - example java script in 'plugins' sample length, Mimetype, suffixes, type.

Sunday, February 7, 2010

Clean URL di localhost xamppClean URLs do not work out of the box on XAMPP


Clean URLs do not work out of the box on XAMPP 1.5.x with PHP4 due to a problem in Apache's module load order; mod_rewrite will not work properly. To remedy this you will need to edit the file [path_to_xampp]/apache/conf/httpd.conf.
mod_rewrite location

Remove the # at the beginning of this line:

LoadModule rewrite_module modules/mod_rewrite.so

and move it to just above or below
#LoadModule cache_module modules/mod_cache.so

AllowOverride

If the mod_rewrite change does not work, you also need to check that AllowOverride All is set for the directory Drupal is in. Do this in httpd.conf or extra/httpd-xampp.conf

Open up file \apache\conf\extra\httpd-xampp.conf

Put this code
Alias /drupal "C:/Program Files/xampp/htdocs/drupal/"
   
      AllowOverride All
      Order allow,deny
      Allow from all
   

Remember to change the path to match your installation location.

If you're not sure where to add it, it might be worth putting it under the entry
 Alias /security "C:/Program Files/xampp/security/htdocs/"
   
    ...
    ...
   


Always restart Apache after you make changes or the changes to its configuration files won't have an effect.
Drupal Directory

If Drupal is not installed in the document root, the next thing you'll have to do is modify the file .htaccess that comes with Drupal. Remove the commentsign (#) in front of RewriteBase and, if necessary, modify the path:

RewriteBase /drupal

Finally, in Drupal go to Administer » Site Configuration » Clean URLs (admin/settings/clean-urls) and run the clean URL test. Then click the "Enabled" option for Clean URLs and save the settings.
READ MORE - Clean URL di localhost xamppClean URLs do not work out of the box on XAMPP

Here are the steps in the installation of drupal 6

Blog about drupal tutorial as it is written on the identity arithok blog will soon begin. About CMS drupal itself, has a lot of content or blogs that discuss strengths when compared to other CMS. Flexible and powerful, two words that I often use when people ask about drupal:). Without the wide long-winded, I started with the following article drupal 6 installation. Oh yes, drupal tutorials on this blog will arithok directly discuss the drupal version 6, and chances are, the blog will not discuss arithok drupal previous versions, since the focus is on the development drupal 6 even, drupal 7 also has developed rapidly.
Initial step before the installation of drupal 6 is to make sure your computer is equipped with a localhost. What is localhost, and how to make the localhost, you can see it on this blog under the title Making arithok Localhost with XAMPP Installation. As in these blogs, XAMPP installation location is in the folder c: / xampp /. If the location of your XAMPP installation folder is different, you can adjust itself when placed drupal files.
Here are the steps in the installation of drupal 6.Download the file from drupal.org drupal 

 
Drupal 6 version which can be downloaded in drupal.org when this tutorial was made 6:14 drupal. When you download it on drupal.org, you'll get the files to install drupal form:
drupal-6.14.tar.gz

These files are compressed files tar.gz. form You must open it first. You can use some software, for example you can use 7-zip. To download, please access http://www.7-zip.org/ URL address. Unpack / unzip / decompress the file, and put the folder drupal-6:14 to location c: / xampp / htdocs /
  
 
Rename the folder drupal-6:14

Rename the folder drupal-6:14 a site name that you want, for example, converted into drupalku. Change the name of this folder will affect the site's URL address in the localhost when you will access via a browser. URL address at localhost to http://localhost/drupalku/
 
Create database drupal

The next step before the installation Drupal 6 is a new database to accommodate data of drupal 6 installation. To make it, you can use phpmyadmin which is available when you create a localhost with XAMPP. Open your browser, then access http://localhost/phpmyadmin/. A little additional explanation, there are some inherent database when making the localhost. The names of the default database comes from XAMPP installation you can see on the left like phpmyadmin, mysql and others.

To create a new database, look at the window on the right. There was a small form with writing on it Create New Database. Please enter the name of your database, for example ari_drupalku. The dropdown menu next to his right, let remain as the default setting of Collation. Then click the Create button.
 
If successful, you will be taken to a new database pages that have been so. You can see on the left, ari_drupalku database name already exists, but the numbers in parentheses 0 indicate that there is no database or data tables in it. This database will be automatically filled in data when Drupal 6 installation process is run.
The final step is to prepare the settings.php file to the database and drupal files in XAMPP can be connected. Go back to your windows explorer, then go to the c: \ xampp \ htdocs \ drupalku \ sites \ default \.In this folder you will find a folder named files and a file named default.settings.php. We will create a settings.php file by copying the files default.settings.php. Way, open the file with notepad default.settings.php. Default.settings.php file right click and select open with notepad. Once open, click the File menu, and select Save As. Change the name to save default.settings.php settings.php, and then below it, change the form save as type to All Files. After that press the Save button. Settings.php file is created and automatically placed in the right place, which is located at the default.settings.php.
Edit settings.php
Now we edit it to customize the database name and the name of the site URL address that we will create. As I mentioned in the first sentence, there are two parts that you need to change in this settings.php file.
=>Enter the user name, password and database name
This step aims to file the installation of drupal 6 can connect to the database that you created earlier. To make it easier, we will use the Find facility in this Notepad editor. Put your cursor at the beginning of this text file by clicking on the top left corner before the Find.
  
Enter the word $ db_url = 'mysql: / / username: password @ localhost / databasename'; and press the Find Next button. When you click the Find Next button, you will find the results of the first text. The first text was hoping to let it go, because this text was not to be changed. Text / first script serves as an example, comes from drupal. Click Find Next once again. Once found, close the box Find. This section we will edit. Text / scrupt is located adjacent second (could also above if you use an editor other than Notepad) 
$ db_prefix. Edit this text from

$db_url = 'mysql://username:password@localhost/databasename'; --> $db_url = 'mysql://root:@localhost/ari_drupalku;
Here's a little explanation of what you change:
username -> root (user name for the default database of XAMPP installation is the root.)
password -> (the password for the default database of XAMPP installation is not using a password, emptied it, remember, vacated, no spaces).
databasename -> ari_drupalku (name of the database you created earlier included here.
When finished changed, press the button on your keyboard Ctrl + S to save the changes, or you can do through the menu with the click Notepad File menu> Save.
=>Entering a URL address
 The second part will be changed in settings.php file is a URL address. Way as the first step when the change / enter a user name, password and database above. Put your cursor at the beginning of this text file with the way in the upper left corner or before Find.
Enter the word "# $ base_url = 'http://www.example.com'; / / NO trailing slash!". Once found, close the search results box, and edit the http://www.example.com -> http://localhost/drupalku
Then press the button on your keyboard Ctrl + S to save the changes, or you can do through the menu with the click Notepad File menu> Save.
Done. Files are finished editing settings.php.

 Installing drupal 6 via a browser
Drupal file is ready, the database is ready, it's time to install drupal via a browser. Open your browser and enter the URL address http://localhost/drupalku/install.php
 
Entering the drupal 6 installation process via a browser, the first time you will be faced with the display language options, select only Install Drupal in Bahasa Indonesia.
 
Wait a minute, the database installation process is running.
The next display is the Configure Site
Here is an explanation of each section:

By default, the file permissions will be changed settings.php during the installation of drupal via the browser, it's for security reasons. All necessary changes to. / Sites / default and. / Sites / default / settings.php have been made. They have been set to read-only for security.
The first part that you need to fill the Site Information.
  • Site Name -> insert name of your site in this form, for example Drupalku. Site name will appear in the upper left corner side by side with drupal logo.
  • Site e-mail address -> enter your email address here for site administration purposes.

The next section is the Server Settings
  • The default time zone. This form serves to set the time to be used on the site. I suggest let alone keep the default, because this is automatically adapts to your computer.
  • Clean URLs This section is important enough for the Disabled (Enabled). Clean URLs will make your site URL into a neat and more familiar to humans and search engines. Default drupal when Clean URLs disabled or is not active, the URL will be used on the site will always use? Q =. This is clearly difficult for visitors to remember our URL address, it was for the search engines something undesirable. Select Enabled Clean URLs for this section. Additional information, using XAMPP, you support the use of localhost url is clean.
 
Complete Instalation drupal

In the next display will appear a message that the installation process is completed. (Drupal installation Compete). However, there is a red warning, snippets following:

warning: mail () [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set () in C: \ xampp \ htdocs \ drupalku \ includes \ mail.inc on line 193.
Unable to send e-mail. Please contact the site administrator if the problem persists.

This warning is normal because you've installed drupal in localhost, localhost is not connected to the internet. This warning explains that the email function does not work and resulted in sending an email to an administrator account failed. This does not matter, when your site is online, email function will work well. You can ignore this warning. You can see the writing underneath that provide safe, that Drupal has been successfully installed. Please proceed to your site pages by clicking on the link your new site.
 
Welcome to your new drupal. You automatically are logged in as admin, in accordance with the administrator user name that you entered earlier. The next tutorial I will explain the parts of drupal so you better understand their respective functions.







READ MORE - Here are the steps in the installation of drupal 6

Saturday, January 9, 2010

JDBC allows multiple implementations to exist and be used by the same application



JDBC is an API for the Java programming language that defines how a client may access a database. It provides methods for querying and updating data in a database. JDBC is oriented towards relational databases.

JDBC was first introduced in the Java 2 Platform, Standard Edition, version 1.1 (J2SE), together with a reference implementation JDBC-to-ODBC bridge, enabling connections to any ODBC-accessible data source in the JVM host environment.

JDBC has been part of the Java Standard Edition since the release of JDK 1.1. The JDBC classes are contained in the Java package java.sql.

Starting with version 3.0, JDBC has been developed under the Java Community Process. JSR 54 specifies JDBC 3.0 (included in J2SE 1.4), JSR 114 specifies the JDBC Rowset additions, and JSR 221 is the specification of JDBC 4.0 (included in Java SE 6).

JDBC allows multiple implementations to exist and be used by the same application. The API provides a mechanism for dynamically loading the correct Java packages and registering them with the JDBC Driver Manager. The Driver Manager is used as a connection factory for creating JDBC connections.

JDBC connections support creating and executing statements. These may be update statements such as SQL's CREATE, INSERT, UPDATE and DELETE, or they may be query statements such as SELECT. Additionally, stored procedures may be invoked through a JDBC connection. JDBC represents statements using one of the following classes:

  1. Statement – the statement is sent to the database server each and every time.
  2. PreparedStatement – the statement is cached and then the execution path is pre determined on the database server allowing it to be executed multiple times in an efficient manner.
  3. CallableStatement – used for executing stored procedures on the database.

The method Class.forName(String) is used to load the JDBC driver class. The line below causes the JDBC driver from some jdbc vendor to be loaded into the application. (Some JVMs also require the class to be instantiated with .newInstance().)

Class.forName( "com.somejdbcvendor.TheirJdbcDriver" );

In JDBC 4.0, it's no longer necessary to explicitly load JDBC drivers using Class.forName(). See JDBC 4.0 Enhancements in Java SE 6.

When a Driver class is loaded, it creates an instance of itself and registers it with the DriverManager. This can be done by including the needed code in the driver class's static block. e.g. DriverManager.registerDriver(Driver driver)

Now when a connection is needed, one of the DriverManager.getConnection() methods is used to create a JDBC connection.

Connection conn = DriverManager.getConnection(
"jdbc:somejdbcvendor:other data needed by some jdbc vendor",
"myLogin",
"myPassword" );

The URL used is dependent upon the particular JDBC driver. It will always begin with the "jdbc:" protocol, but the rest is up to the particular vendor. Once a connection is established, a statement must be created.

Statement stmt = conn.createStatement();
try {
stmt.executeUpdate( "INSERT INTO MyTable( name ) VALUES ( 'my name' ) " );
} finally {
//It's important to close the statement when you are done with it
stmt.close();
}

Note that Connections, Statements, and ResultSets often tie up operating system resources such as sockets or file descriptors. In the case of Connections to remote database servers, further resources are tied up on the server, e.g., cursors for currently open ResultSets. It is vital to close() any JDBC object as soon as it has played its part; garbage collection should not be relied upon. Forgetting to close() things properly results in spurious errors and misbehaviour. The above try-finally construct is a recommended code pattern to use with JDBC objects.

Data is retrieved from the database using a database query mechanism. The example below shows creating a statement and executing a query.

Statement stmt = conn.createStatement();
try {
ResultSet rs = stmt.executeQuery( "SELECT * FROM MyTable" );
try {
while ( rs.next() ) {
int numColumns = rs.getMetaData().getColumnCount();
for ( int i = 1 ; i <= numColumns ; i++ ) {
// Column numbers start at 1.
// Also there are many methods on the result set to return
// the column as a particular type. Refer to the Sun documentation
// for the list of valid conversions.
System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );
}
}
} finally {
rs.close();
}
} finally {
stmt.close();
}

Typically, however, it would be rare for a seasoned Java programmer to code in such a fashion. The usual practice would be to abstract the database logic into an entirely different class and to pass preprocessed strings (perhaps derived themselves from a further abstracted class) containing SQL statements and the connection to the required methods. Abstracting the data model from the application code makes it more likely that changes to the application and data model can be made independently.

An example of a PreparedStatement query, using conn and class from first example.

PreparedStatement ps = conn.prepareStatement( "SELECT i.*, j.* FROM Omega i, Zappa j WHERE i.name = ? AND j.num = ?" );
try {
// In the SQL statement being prepared, each question mark is a placeholder
// that must be replaced with a value you provide through a "set" method invocation.
// The following two method calls replace the two placeholders; the first is
// replaced by a string value, and the second by an integer value.
ps.setString(1, "Poor Yorick");
ps.setInt(2, 8008);

// The ResultSet, rs, conveys the result of executing the SQL statement.
// Each time you call rs.next(), an internal row pointer, or cursor,
// is advanced to the next row of the result. The cursor initially is
// positioned before the first row.
ResultSet rs = ps.executeQuery();
try {
while ( rs.next() ) {
int numColumns = rs.getMetaData().getColumnCount();
for ( int i = 1 ; i <= numColumns ; i++ ) {
// Column numbers start at 1.
// Also there are many methods on the result set to return
// the column as a particular type. Refer to the Sun documentation
// for the list of valid conversions.
System.out.println( "COLUMN " + i + " = " + rs.getObject(i) );
} // for
} // while
} finally {
rs.close();
}
} finally {
ps.close();
} // try

When a database operation fails, an SQLException is raised. There is typically very little one can do to recover from such an error, apart from logging it with as much detail as possible. It is recommended that the SQLException be translated into an application domain exception (an unchecked one) that eventually results in a transaction rollback and a notification to the user.


Here are examples of host database types which Java can convert to with a function.




setXXX() Methods Oracle Datatype setXXX()

CHAR setString()

VARCHAR2 setString()

NUMBER
setBigDecimal()
setBoolean()
setByte()
setShort()
setInt()
setLong()
setFloat()
setDouble()

INTEGER setInt()

FLOAT setDouble()

CLOB setClob()
BLOB setBlob()
RAW setBytes()
LONGRAW setBytes()

DATE
setDate()
setTime()
setTimestamp()

Types

There are commercial and free drivers available for most relational database servers. These drivers fall into one of the following types:

* Type 1 that calls native code of the locally available ODBC driver.
* Type 2 that calls database vendor native library on a client side. This code then talks to database over network.
* Type 3, the pure-java driver that talks with the server-side middleware that then talks to database
* Type 4, the pure-java driver that uses database native protocol

Internal JDBC driver, driver embedded with JRE in Java-enabled SQL databases. Used for Java stored procedures. This does not belong to the above classification, although it would likely be either a type 2 or type 4 driver (depending on whether the database itself is implemented in Java or not). An example of this is the KPRB driver supplied with Oracle RDBMS. "jdbc:default:connection" is a relatively standard way of referring making such a connection (at least Oracle and Apache Derby support it). The distinction here is that the JDBC client is actually running as part of the database being accessed, so access can be made directly rather than through network protocols.

Sources

  1. SQLSummit.com publishes list of drivers, including JDBC drivers and vendors
  2. Sun Microsystems provides a list of some JDBC drivers and vendors
  3. Simba Technologies ships an SDK for building custom JDBC Drivers for any custom/proprietary relational data source
  4. DataDirect Technologies provides a comprehensive suite of fast Type 4 JDBC drivers for all major database
  5. IDS Software provides a Type 3 JDBC driver for concurrent access to all major databases. Supported features include resultset caching, SSL encryption, custom data source, dbShield.
  6. OpenLink Software ships JDBC Drivers for a variety of databases, including Bridges to other data access mechanisms (e.g., ODBC, JDBC) which can provide more functionality than the targeted mechanism
  7. JDBaccess is a Java persistence library for MySQL and Oracle which defines major database access operations in an easy usable API above JDBC
  8. JNetDirect provides a suite of fully Sun J2EE certified high performance JDBC drivers.
  9. HSQL is a RDBMS with a JDBC driver and is available under a BSD license.
  10. SchemaCrawler is an open source API that leverages JDBC, and makes database metadata available as plain old Java objects (POJOs)


    READ MORE - JDBC allows multiple implementations to exist and be used by the same application

    Wednesday, January 6, 2010

    Database Management System (DBMS)

    Data Model

    A database system is a term that is typically used to encapsulate the constructs of a data model, database Management system (DBMS) and database.

    A database is an organised pool of logically-related data. Data is stored within the data structures of the database. A DBMS is a suite of computer software providing the interface between users and a database or databases. A DBMS is a shell which surrounds a database or series of databases and through which all interactions take place with the database. The interactions catered for by most existing DBMS fall into 4 main groups:

    1. Data Definition. Defining new data structures for a database, removing data structures from the database, modifying the structure of existing data.
    2. Data Maintenance. Inserting new data into existing data structures, updating data in existing data structures, deleting data from existing data structures.
    3. Data Retrieval. Querying existing data by end-users and extracting data for use by application programs.
    4. Data Control. Creating and monitoring users of the database, restricting access to data in the database and monitoring the performance of databases.

    Both a database and its DBMS conform to the principles of a particular data model. Data models include the hierarchical data model, the network data model, the relational data model and the object-oriented data model.

    A data model in software engineering is an abstract model that describes how data is represented and accessed. Data models formally define data elements and relationships among data elements for a domain of interest. According to Hoberman (2009), "A data model is a wayfinding tool for both business and IT professionals, which uses a set of symbols and text to precisely explain a subset of real information to improve communication within the organization and thereby lead to a more flexible and stable application environment."

    A data model explicitly determines the meaning of data, which in this case is known as structured data (as opposed to unstructured data, for example an image, a binary file or a natural language text, where the meaning has to be elaborated). Typical applications of data models include database models, design of information systems, and enabling exchange of data. Usually data models are specified in a data modeling language.

    Communication and precision are the two key benefits that make a data model important to applications that use and exchange data. A data model is the medium which project team members from different backgrounds and with different levels of experience can communicate with one another. Precision means that the terms and rules on a data model can be interpreted only one way and are not ambiguous.

    A data model can be sometimes referred to as a data structure, especially in the context of programming languages. Data models are often complemented by function models, especially in the context of enterprise models.

    A database model is a theory or specification describing how a database is structured and used. Several such models have been suggested. Common models include:

     Flat model
    Hierarchical model
     Network model
    Relational model
     Concept-oriented model
     Star schema
    1. Flat model: This may not strictly qualify as a data model. The flat (or table) model consists of a single, two-dimensional array of data elements, where all members of a given column are assumed to be similar values, and all members of a row are assumed to be related to one another.
    2. Hierarchical model: In this model data is organized into a tree-like structure, implying a single upward link in each record to describe the nesting, and a sort field to keep the records in a particular order in each same-level list.
    3. Network model: This model organizes data using two fundamental constructs, called records and sets. Records contain fields, and sets define one-to-many relationships between records: one owner, many members.
    4. Relational model: is a database model based on first-order predicate logic. Its core idea is to describe a database as a collection of predicates over a finite set of predicate variables, describing constraints on the possible values and combinations of values.
    5. Object-relational model: Similar to a relational database model, but objects, classes and inheritance are directly supported in database schemas and in the query language.
    6. Star schema is the simplest style of data warehouse schema. The star schema consists of a few "fact tables" (possibly only one, justifying the name) referencing any number of "dimension tables". The star schema is considered an important special case of the snowflake schema.
    A Database Management System (DBMS) is a set of computer programs that controls the creation, maintenance, and the use of the database with computer as a platform or of an organization and its end users. It allows organizations to place control of organization-wide database development in the hands of database administrators (DBAs) and other specialists. A DBMS is a system software package that helps the use of integrated collection of data records and files known as databases. It allows different user application programs to easily access the same database. DBMSs may use any of a variety of database models, such as the network model or relational model. In large systems, a DBMS allows users and other software to store and retrieve data in a structured way. Instead of having to write computer programs to extract information, user can ask simple questions in a query language. Thus, many DBMS packages provide Fourth-generation programming language (4GLs) and other application development features. It helps to specify the logical organization for a database and access and use the information within a database. It provides facilities for controlling data access, enforcing data integrity, managing concurrency controlled, restoring database.

    A DBMS is a set of software programs that controls the organization, storage, management, and retrieval of data in a database. DBMSs are categorized according to their data structures or types. The DBMS accepts requests for data from an application program and instructs the operating system to transfer the appropriate data. The queries and responses must be submitted and received according to a format that conforms to one or more applicable protocols. When a DBMS is used, information systems can be changed much more easily as the organization's information requirements change. New categories of data can be added to the database without disruption to the existing system.

    Database servers are computers that hold the actual databases and run only the DBMS and related software. Database servers are usually multiprocessor computers, with generous memory and RAID disk arrays used for stable storage. Hardware database accelerators, connected to one or more servers via a high-speed channel, are also used in large volume transaction processing environments. DBMSs are found at the heart of most database applications. Sometimes DBMSs are built around a private multitasking kernel with built-in networking support although nowadays these functions are left to the operating system.

    A DBMS includes four main parts: modeling language, data structure, database query language, and transaction mechanisms:

    Components of DBMS
    DBMS Engine accepts logical request from the various other DBMS subsystems, converts them into physical equivalent, and actually accesses the database and data dictionary as they exist on a storage device.
    Data Definition Subsystem helps user to create and maintain the data dictionary and define the structure of the files in a database.
    Data Manipulation Subsystem helps user to add, change, and delete information in a database and query it for valuable information. Software tools within the data manipulation subsystem are most often the primary interface between user and the information contained in a database. It allows user to specify its logical information requirements.
    Application Generation Subsystem contains facilities to help users to develop transactions-intensive applications. It usually requires that user perform a detailed series of tasks to process a transaction. It facilities easy-to-use data entry screens, programming languages, and interfaces.
    Data Administration Subsystem helps users to manage the overall database environment by providing facilities for backup and recovery, security management, query optimization, concurrency control, and change management.

    Modeling language

    A data modeling language to define the schema of each database hosted in the DBMS, according to the DBMS database model. The four most common types of models are the:
    hierarchical model,
    network model,
    relational model, and
    object model.

    Inverted lists and other methods are also used. A given database management system may provide one or more of the four models. The optimal structure depends on the natural organization of the application's data, and on the application's requirements (which include transaction rate (speed), reliability, maintainability, scalability, and cost).

    The dominant model in use today is the ad hoc one embedded in SQL, despite the objections of purists who believe this model is a corruption of the relational model, since it violates several of its fundamental principles for the sake of practicality and performance. Many DBMSs also support the Open Database Connectivity API that supports a standard way for programmers to access the DBMS.

    Before the database management approach, organizations relied on file processing systems to organize, store, and process data files. End users became aggravated with file processing because data is stored in many different files and each organized in a different way. Each file was specialized to be used with a specific application. Needless to say, file processing was bulky, costly and nonflexible when it came to supplying needed data accurately and promptly. Data redundancy is an issue with the file processing system because the independent data files produce duplicate data so when updates were needed each separate file would need to be updated. Another issue is the lack of data integration. The data is dependent on other data to organize and store it. Lastly, there was not any consistency or standardization of the data in a file processing system which makes maintenance difficult. For all these reasons, the database management approach was produced. Database management systems (DBMS) are designed to use one of five database structures to provide simplistic access to information stored in databases. The five database structures are hierarchical, network, relational, multidimensional and object-oriented models.

    The hierarchical structure was used in early mainframe DBMS. Records’ relationships form a treelike model. This structure is simple but nonflexible because the relationship is confined to a one-to-many relationship. IBM’s IMS system and the RDM Mobile are examples of a hierarchical database system with multiple hierarchies over the same data. RDM Mobile is a newly designed embedded database for a mobile computer system. The hierarchical structure is used primary today for storing geographic information and file systems.

    The network structure consists of more complex relationships. Unlike the hierarchical structure, it can relate to many records and accesses them by following one of several paths. In other words, this structure allows for many-to-many relationships.

    The relational structure is the most commonly used today. It is used by mainframe, midrange and microcomputer systems. It uses two-dimensional rows and columns to store data. The tables of records can be connected by common key values. While working for IBM, E.F. Codd designed this structure in 1970. The model is not easy for the end user to run queries with because it may require a complex combination of many tables.

    The multidimensional structure is similar to the relational model. The dimensions of the cube looking model have data relating to elements in each cell. This structure gives a spreadsheet like view of data. This structure is easy to maintain because records are stored as fundamental attributes, the same way they’re viewed and the structure is easy to understand. Its high performance has made it the most popular database structure when it comes to enabling online analytical processing (OLAP).

    The object oriented structure has the ability to handle graphics, pictures, voice and text, types of data, without difficultly unlike the other database structures. This structure is popular for multimedia Web-based applications. It was designed to work with object-oriented programming languages such as Java.
    READ MORE - Database Management System (DBMS)
     
    THANK YOU FOR VISITING