Test

Powered by Blogger.

Saturday, 21 July 2012

Samsung Series 7 Gamer Hands-on: Watch Out, Alienware

Serious gamers, take note: Samsung is throwing down the gauntlet with the Series 7 Gamer. We got a first look today at CES at the 17-inch system, a top of the line desktop replacement that looks to blow away Alienware’s benchmark scores– and maybe even its battery life, too.


Razer Blade Hands-On: Lightest-Ever 17-inch Gaming Laptop Has Touchscreen TouchPad

Razer’s long-awaited entry into the notebook space is finally here in the flesh, and it was worth the wait.  the company, which is best known for gaming accessories like mice and keyboards, showed off the Razer

wireless display for android

LAS VEGAS — Soon you may be able to play a game on your tablet while wirelessly streaming a movie from the same device to your home theater system. Today at CES, Texas Instruments showcased its OMAP 4400 series CPU’s support for wireless display technology and ability to display different content on the tablet than on the screen to which it’s streaming.


For years, Windows notebook users have been able to send video wirelessly to TVs via technologies like Intel’s WiDi and WHDI. However, Android users have been left out in the cold. That could be changing very soon as TI showed today that its current generation of TI OMAP 4400 series, which are already in millions of devices, are capable of streaming content via the wireless display protocol.
n one demonstration, a TI representative showed us a TI reference tablet with an OMAP 4400 series processor that was capable of playing Angry Birds on its own screen while sending a full HD movie to a TV via wireless. Though end users cannot do this today, TI told us that existing tablets and phones with OMAP could perform this function with the right software and the right receiver on the other end.

If you’re streaming HD video, TI told us, you actually won’t eat up too many system resources, because video is offloaded onto OMAP’ 4400 series’ secondary, low-power media cores. The primary CPU cores are free to focus all their might on your other app, whether it’s your email client or a game of Riptide. So you can play your game while you also watching TV on the big screen, definitely a boon for those with short attention span

Iconia tab

LAS VEGAS — Priced between the Kindle Fire and iPad 2, the Acer Iconia Tab attempts to tempt tablet shoppers with Tegra 2 power at an affordable price. It goes on sale January 15th for $329 for 8GB and just $349 for 16GB. We just spent a few minutes with this 10-incher at CES 2012, and it’s a slate that’s stripped down in some ways but has a unique ring interface.


Check out our video of the A200 below, along with our hands-on impressions and photos.

In order to keep the price low, Acer decided to nix the camera on the back, which the Iconia Tab A500 had. Since most folks probably don’t want to use their tablets as camcorders, this feature likely won’t be missed. However, Acer did keep the full-size USB port, which you can use to plug in a mouse, keyboard or even wireless game controller should you decide to hook the A200 up to a TV to play games like Shadowgun.
he most unique thing about the Iconia Tab A200 is the ring interface, activated by pressing a circle at the bottom of the screen. You’ll see a circular UI pop up with shortcuts for the browser (complete with thumbnails of your favorite sites fanned out), for taking a screenshot, Settings and Gallery. You can also control the volume from this menu. Acer says you should also be able to customize the ring UI.

Although the A200 will launch with Honeycomb, Acer told us to expect an upgrade to Ice Cream Sandwich in February. No, the Iconia Tab A200 isn’t as sexy as the quad core-packing, full HD A700, but it looks like a solid bread-and-butter Android tablet that makes the right trade-offs for its price. Stay tuned for a full review.

DB technologies

Emerging database technologies
"Main memory databases are faster than disk-optimized databases, as the internal optimization algorithms are simpler and execute fewer CPU instructions. Accessing data in memory provides faster and more predictable performance than disk. In applications, where response time is critical, such as telecommunications network equipment that operates
emergency systems, main memory
databases are often used"
- Sanjay Mehta
CEO of MAIA Intelligence
Of late, the industry has seen the emergence of business intelligence and data warehousing as a major factor influencing business decisions. Businesses have gone past the ‘applications’ phase to a phase where useful, accurate and timely information from application data is being used to make better business decisions.

Databases have also begun to align with this shift in customers’ needs. They continue to be the heart of transaction processing; but there is a definite shift in focus towards providing databases that support superior performance as far as reporting, analytics and data mining are concerned. The trend towards the use of databases for mining useful, accurate information has led to the creation of a new category of databases. 

“Sybase IQ uses a patented columnar architecture that provides superior performance in querying and reporting. It works with any transactional database at the back end and with any reporting software on the front,” said Sudesh Prabhu, Director - Presales and Services, Sybase India.
Moreover, the adoption of specialty servers is growing and customers are moving away from increasingly constrained row-based databases for analytics and data warehousing. There is greater demand for advanced analytics to uncover business opportunities and risk, thereby driving demand for forecasting, predictive modeling and data mining. The market is also seeing the integration of all data types into BI, wherein traditional plus streaming data, non-relational/ unstructured data, (XML data, geospatial data and media) is taking place.
Some of the other latest databases that are being deployed by Indian organizations are Oracle 11g (includes high availability solution), SQL Server 2008 (also includes high availability solution), and DB2/UDB V9.0.
Meanwhile, many of the latest database technologies not only help in solving exotic data warehouse or other intensive number-crunching problems but also real-world data management problems.
Sophisticated analytics to outsmart the competition is emerging as a must-have business practice in many industries. Vast amounts of current and historical data must be run against intricate analytical models to accurately predict future outcomes.
However, these analytics systems are where the data explosion has had the most impact. Implementing more efficient analytics software, therefore, can solve not only the data explosion and its byproduct (rampant energy use) but also dramatically increase the speed, scalability, and flexibility of business intelligence.

Next generation Database

Next-generation database technologies
There is a need for a third-generation of database technologies, as we are forced to embrace a world of large-memory models, clustered servers, and highly compressed column-wise storage. 


Although database management systems (DBMS) technology has matured, there remains potential for innovation in integrating structured and unstructured data, virtualizing access to data, and simplifying data management through greater automation and intelligence.
 


DBMS technology and middleware will also evolve to support the information fabric by virtualizing access to heterogeneous data. These trends will offer an evolutionary path to a future world of information management in which all forms of information will be easier to access, integrate, and control, and this will all come at a lower cost, due to increased automation. 

Many organizations will move to upgrade or expand existing legacy networks and infrastructure; hence the database market will see lots of activity and increased competition in an already mature space.
According to IDC reports, most data warehouses will be stored in a columnar fashion and not in rows, reporting and data collection problems will be solved with databases that have no formal schema at all, horizontal scalability through clustering will be achieved by large-scale database servers; and most OLTP databases will either reside entirely in memory or be augmented by an in-memory database.
These new systems will encourage companies to forget disk-based partitioning schemes, buffer management, indexing strategies and embrace a world of large-memory models, many processors with many cores, clustered servers and highly compressed column wise storage. 

Springboard Research reports suggest that databases are critical for data intensive environments like banking, financial services and insurance telecom, retail and PSU. Sanchit Vir Gogia, Associate Research Manager - Software, Springboard Research said that India as a market for DBMS is at an inflection point. While large enterprises are clearly dedicating a portion of their IT budget to better manage data, SMBs are also waking up to these benefits. Interestingly, investment in DBMS by SMBs is largely driven through the pent-up demand for enterprise applications like ERP, CRM, etc.

Wednesday, 18 July 2012

JDBC basics

The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.




JDBC helps you to write java applications that manage these three programming activities:
  1. Connect to a database
  2. Send queries and update statements to the database
  3. Retrieve and process the results with database.

     
     
     
    Connection con = DriverManager.getConnection
               ( "jdbc:myDriver:wombat", "myLogin","myPassword");
         
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
    while (rs.next()) {
     int x = rs.getInt("a");
     String s = rs.getString("b");
     float f = rs.getFloat("c");
     }
    This short code fragment instantiates a DriverManager object to connect to a database driver and log into the database, instantiates a Statement object that carries your SQL language query to the database; instantiates a ResultSet object that retrieves the results of your query, and executes a simple while loop, which retrieves and displays those results.



JDBC includes four components:
  1. The JDBC API 

    The JDBC™ API provides programmatic access to relational data from the Java™ programming language. Using the JDBC API, applications can execute SQL statements, retrieve results, and propagate changes back to an underlying data source. The JDBC API can also interact with multiple data sources in a distributed, heterogeneous environment.


    The JDBC API is part of the Java platform, which includes the
    Java™ Standard Edition (Java™ SE ) and the Java™ Enterprise Edition (Java™ EE). The JDBC 4.0 API is divided into two packages: java.sql and javax.sql. Both packages are included in the Java SE and Java EE platforms.

  2. JDBC Driver Manager 

    The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture.

    The Standard Extension packages javax.naming and javax.sql let you use a DataSource object registered with a Java Naming and Directory Interface™ (JNDI) naming service to establish a connection with a data source. You can use either connecting mechanism, but using a DataSource object is recommended whenever possible.
  3. JDBC Test Suite

    The JDBC driver test suite helps you to determine that JDBC drivers will run your program. These tests are not comprehensive or exhaustive, but they do exercise many of the important features in the JDBC API.
  4. JDBC-ODBC Bridge

    The Java Software bridge provides JDBC access via ODBC drivers. Note that you need to load ODBC binary code onto each client machine that uses this driver. As a result, the ODBC driver is most appropriate on a corporate network where client installations are not a major problem, or for application server code written in Java in a three-tier architecture.
This Trail uses the first two of these these four JDBC components to connect to a database and then build a java program that uses SQL commands to communicate with a test Relational Database. The last two components are used in specialized environments to test web applications, or to communicate with ODBC-aware DBMSs.

JDBC Architecture

Two-tier and Three-tier Processing Models

The JDBC API supports both two-tier and three-tier processing models for database access.

Figure 1: Two-tier Architecture for Data Access.



In the two-tier model, a Java applet or application talks directly to the data source. This requires a JDBC driver that can communicate with the particular data source being accessed. A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user. The data source may be located on another machine to which the user is connected via a network. This is referred to as a client/server configuration, with the user's machine as the client, and the machine housing the data source as the server. The network can be an intranet, which, for example, connects employees within a corporation, or it can be the Internet.

In the three-tier model, commands are sent to a "middle tier" of services, which then sends the commands to the data source. The data source processes the commands and sends the results back to the middle tier, which then sends them to the user. MIS directors find the three-tier model very attractive because the middle tier makes it possible to maintain control over access and the kinds of updates that can be made to corporate data. Another advantage is that it simplifies the deployment of applications. Finally, in many cases, the three-tier architecture can provide performance advantages.
Figure 2: Three-tier Architecture for Data Access.
The DBMS-proprietary protocol provides two-way communication between the database server and the server machine. HTTP, RMI, CORBA or other calls provide two way communication between the server machine and the client machine

Until recently, the middle tier has often been written in languages such as C or C++, which offer fast performance. However, with the introduction of optimizing compilers that translate Java bytecode into efficient machine-specific code and technologies such as Enterprise JavaBeans™, the Java platform is fast becoming the standard platform for middle-tier development. This is a big plus, making it possible to take advantage of Java's robustness, multithreading, and security features.

With enterprises increasingly using the Java programming language for writing server code, the JDBC API is being used more and more in the middle tier of a three-tier architecture. Some of the features that make JDBC a server technology are its support for connection pooling, distributed transactions, and disconnected rowsets. The JDBC API is also what allows access to a data source from a Java middle tier.

Storing image in db using jdbc

Assuming you have a table with a blob field and you want to save a file and store it in the database table or you want to read from a blob object stored in a database, you can use these below java code snippets to write file and read file from database.
The sample table is created as below to have a blob field to store file.


CREATE TABLE t1 (c1 INT PRIMARY KEY NOT NULL, c2 BLOB(5M));


Then use the below code snippet to insert an image file as follows.
 
PreparedStatement pstmt = conn.prepareStatement ("INSERT INTO t1 VALUES (?,?)");
pstmt.setInt (1, 100);
File fBlob = new File ( "image1.gif" );
FileInputStream is = new FileInputStream ( fBlob );
pstmt.setBinaryStream (2, is, (int) fBlob.length() );
pstmt.execute ();
...

 

Retrieving a BLOB or in other words retrieving the image file stored in the database as follows:
 
Statement stmt = conn.createStatement ();
ResultSet rs= stmt.executeQuery("SELECT * FROM t1");
while(rs.next()) {
int val1 = rs.getInt(1);
InputStream val2 = rs.getBinaryStream(2);
...
} rs.close();

sending mail through java

SENDING MAIL THROUGH JAVA
You can use the JavaMail API to send emails from your Java application. Though the JavaMail API allows you to do many things including the ability to retrieve and read the emails or sending emails etc, this sample java program demonstrates how to send email from your Java application. Remember to change the email host (String host) to your email server host, otherwise it won't work. import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SimpleSendEmail {
public static void main(String[] args) {
// Collect the necessary information to send a simple message
// Make sure to replace the values for host, to, and from with
// valid information.
// host - must be a valid smtp server that you currently have
// access to.
// to - whoever is going to get your email
// from - whoever you want to be. Just remember that many smtp
// servers will validate the domain of the from address
// before allowing the mail to be sent.

String host = "server.myhost.com";
String to = "YourFriend@someemail.com";
String from = "Me@myhost.com";
String subject = "My First Email";
String messageText = "I am sending a message using the"
+ " JavaMail API.\n"
+ "Here type your message.";
boolean sessionDebug = false;
// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session session = Session.getDefaultInstance(props, null);
// Set debug on the Session so we can see what is going on
// Passing false will not echo debug info, and passing true
// will.

session.setDebug(sessionDebug);
try {
// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
}
catch (MessagingException mex) {
mex.printStackTrace();
}
}
}

RSS

Categories

Followers

Blog Archive

rTechIndia

RtechIndia->technology ahead

rtech

rtechindia

RtechIndia

Go rtechindia

Go rtechindia

RtechIndia

Saturday, 21 July 2012

Samsung Series 7 Gamer Hands-on: Watch Out, Alienware

Serious gamers, take note: Samsung is throwing down the gauntlet with the Series 7 Gamer. We got a first look today at CES at the 17-inch system, a top of the line desktop replacement that looks to blow away Alienware’s benchmark scores– and maybe even its battery life, too.


Razer Blade Hands-On: Lightest-Ever 17-inch Gaming Laptop Has Touchscreen TouchPad

Razer’s long-awaited entry into the notebook space is finally here in the flesh, and it was worth the wait.  the company, which is best known for gaming accessories like mice and keyboards, showed off the Razer

wireless display for android

LAS VEGAS — Soon you may be able to play a game on your tablet while wirelessly streaming a movie from the same device to your home theater system. Today at CES, Texas Instruments showcased its OMAP 4400 series CPU’s support for wireless display technology and ability to display different content on the tablet than on the screen to which it’s streaming.


For years, Windows notebook users have been able to send video wirelessly to TVs via technologies like Intel’s WiDi and WHDI. However, Android users have been left out in the cold. That could be changing very soon as TI showed today that its current generation of TI OMAP 4400 series, which are already in millions of devices, are capable of streaming content via the wireless display protocol.
n one demonstration, a TI representative showed us a TI reference tablet with an OMAP 4400 series processor that was capable of playing Angry Birds on its own screen while sending a full HD movie to a TV via wireless. Though end users cannot do this today, TI told us that existing tablets and phones with OMAP could perform this function with the right software and the right receiver on the other end.

If you’re streaming HD video, TI told us, you actually won’t eat up too many system resources, because video is offloaded onto OMAP’ 4400 series’ secondary, low-power media cores. The primary CPU cores are free to focus all their might on your other app, whether it’s your email client or a game of Riptide. So you can play your game while you also watching TV on the big screen, definitely a boon for those with short attention span

Iconia tab

LAS VEGAS — Priced between the Kindle Fire and iPad 2, the Acer Iconia Tab attempts to tempt tablet shoppers with Tegra 2 power at an affordable price. It goes on sale January 15th for $329 for 8GB and just $349 for 16GB. We just spent a few minutes with this 10-incher at CES 2012, and it’s a slate that’s stripped down in some ways but has a unique ring interface.


Check out our video of the A200 below, along with our hands-on impressions and photos.

In order to keep the price low, Acer decided to nix the camera on the back, which the Iconia Tab A500 had. Since most folks probably don’t want to use their tablets as camcorders, this feature likely won’t be missed. However, Acer did keep the full-size USB port, which you can use to plug in a mouse, keyboard or even wireless game controller should you decide to hook the A200 up to a TV to play games like Shadowgun.
he most unique thing about the Iconia Tab A200 is the ring interface, activated by pressing a circle at the bottom of the screen. You’ll see a circular UI pop up with shortcuts for the browser (complete with thumbnails of your favorite sites fanned out), for taking a screenshot, Settings and Gallery. You can also control the volume from this menu. Acer says you should also be able to customize the ring UI.

Although the A200 will launch with Honeycomb, Acer told us to expect an upgrade to Ice Cream Sandwich in February. No, the Iconia Tab A200 isn’t as sexy as the quad core-packing, full HD A700, but it looks like a solid bread-and-butter Android tablet that makes the right trade-offs for its price. Stay tuned for a full review.

DB technologies

Emerging database technologies
"Main memory databases are faster than disk-optimized databases, as the internal optimization algorithms are simpler and execute fewer CPU instructions. Accessing data in memory provides faster and more predictable performance than disk. In applications, where response time is critical, such as telecommunications network equipment that operates
emergency systems, main memory
databases are often used"
- Sanjay Mehta
CEO of MAIA Intelligence
Of late, the industry has seen the emergence of business intelligence and data warehousing as a major factor influencing business decisions. Businesses have gone past the ‘applications’ phase to a phase where useful, accurate and timely information from application data is being used to make better business decisions.

Databases have also begun to align with this shift in customers’ needs. They continue to be the heart of transaction processing; but there is a definite shift in focus towards providing databases that support superior performance as far as reporting, analytics and data mining are concerned. The trend towards the use of databases for mining useful, accurate information has led to the creation of a new category of databases. 

“Sybase IQ uses a patented columnar architecture that provides superior performance in querying and reporting. It works with any transactional database at the back end and with any reporting software on the front,” said Sudesh Prabhu, Director - Presales and Services, Sybase India.
Moreover, the adoption of specialty servers is growing and customers are moving away from increasingly constrained row-based databases for analytics and data warehousing. There is greater demand for advanced analytics to uncover business opportunities and risk, thereby driving demand for forecasting, predictive modeling and data mining. The market is also seeing the integration of all data types into BI, wherein traditional plus streaming data, non-relational/ unstructured data, (XML data, geospatial data and media) is taking place.
Some of the other latest databases that are being deployed by Indian organizations are Oracle 11g (includes high availability solution), SQL Server 2008 (also includes high availability solution), and DB2/UDB V9.0.
Meanwhile, many of the latest database technologies not only help in solving exotic data warehouse or other intensive number-crunching problems but also real-world data management problems.
Sophisticated analytics to outsmart the competition is emerging as a must-have business practice in many industries. Vast amounts of current and historical data must be run against intricate analytical models to accurately predict future outcomes.
However, these analytics systems are where the data explosion has had the most impact. Implementing more efficient analytics software, therefore, can solve not only the data explosion and its byproduct (rampant energy use) but also dramatically increase the speed, scalability, and flexibility of business intelligence.

Next generation Database

Next-generation database technologies
There is a need for a third-generation of database technologies, as we are forced to embrace a world of large-memory models, clustered servers, and highly compressed column-wise storage. 


Although database management systems (DBMS) technology has matured, there remains potential for innovation in integrating structured and unstructured data, virtualizing access to data, and simplifying data management through greater automation and intelligence.
 


DBMS technology and middleware will also evolve to support the information fabric by virtualizing access to heterogeneous data. These trends will offer an evolutionary path to a future world of information management in which all forms of information will be easier to access, integrate, and control, and this will all come at a lower cost, due to increased automation. 

Many organizations will move to upgrade or expand existing legacy networks and infrastructure; hence the database market will see lots of activity and increased competition in an already mature space.
According to IDC reports, most data warehouses will be stored in a columnar fashion and not in rows, reporting and data collection problems will be solved with databases that have no formal schema at all, horizontal scalability through clustering will be achieved by large-scale database servers; and most OLTP databases will either reside entirely in memory or be augmented by an in-memory database.
These new systems will encourage companies to forget disk-based partitioning schemes, buffer management, indexing strategies and embrace a world of large-memory models, many processors with many cores, clustered servers and highly compressed column wise storage. 

Springboard Research reports suggest that databases are critical for data intensive environments like banking, financial services and insurance telecom, retail and PSU. Sanchit Vir Gogia, Associate Research Manager - Software, Springboard Research said that India as a market for DBMS is at an inflection point. While large enterprises are clearly dedicating a portion of their IT budget to better manage data, SMBs are also waking up to these benefits. Interestingly, investment in DBMS by SMBs is largely driven through the pent-up demand for enterprise applications like ERP, CRM, etc.

Wednesday, 18 July 2012

JDBC basics

The JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database.




JDBC helps you to write java applications that manage these three programming activities:
  1. Connect to a database
  2. Send queries and update statements to the database
  3. Retrieve and process the results with database.

     
     
     
    Connection con = DriverManager.getConnection
               ( "jdbc:myDriver:wombat", "myLogin","myPassword");
         
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
    while (rs.next()) {
     int x = rs.getInt("a");
     String s = rs.getString("b");
     float f = rs.getFloat("c");
     }
    This short code fragment instantiates a DriverManager object to connect to a database driver and log into the database, instantiates a Statement object that carries your SQL language query to the database; instantiates a ResultSet object that retrieves the results of your query, and executes a simple while loop, which retrieves and displays those results.



JDBC includes four components:
  1. The JDBC API 

    The JDBC™ API provides programmatic access to relational data from the Java™ programming language. Using the JDBC API, applications can execute SQL statements, retrieve results, and propagate changes back to an underlying data source. The JDBC API can also interact with multiple data sources in a distributed, heterogeneous environment.


    The JDBC API is part of the Java platform, which includes the
    Java™ Standard Edition (Java™ SE ) and the Java™ Enterprise Edition (Java™ EE). The JDBC 4.0 API is divided into two packages: java.sql and javax.sql. Both packages are included in the Java SE and Java EE platforms.

  2. JDBC Driver Manager 

    The JDBC DriverManager class defines objects which can connect Java applications to a JDBC driver. DriverManager has traditionally been the backbone of the JDBC architecture.

    The Standard Extension packages javax.naming and javax.sql let you use a DataSource object registered with a Java Naming and Directory Interface™ (JNDI) naming service to establish a connection with a data source. You can use either connecting mechanism, but using a DataSource object is recommended whenever possible.
  3. JDBC Test Suite

    The JDBC driver test suite helps you to determine that JDBC drivers will run your program. These tests are not comprehensive or exhaustive, but they do exercise many of the important features in the JDBC API.
  4. JDBC-ODBC Bridge

    The Java Software bridge provides JDBC access via ODBC drivers. Note that you need to load ODBC binary code onto each client machine that uses this driver. As a result, the ODBC driver is most appropriate on a corporate network where client installations are not a major problem, or for application server code written in Java in a three-tier architecture.
This Trail uses the first two of these these four JDBC components to connect to a database and then build a java program that uses SQL commands to communicate with a test Relational Database. The last two components are used in specialized environments to test web applications, or to communicate with ODBC-aware DBMSs.

JDBC Architecture

Two-tier and Three-tier Processing Models

The JDBC API supports both two-tier and three-tier processing models for database access.

Figure 1: Two-tier Architecture for Data Access.



In the two-tier model, a Java applet or application talks directly to the data source. This requires a JDBC driver that can communicate with the particular data source being accessed. A user's commands are delivered to the database or other data source, and the results of those statements are sent back to the user. The data source may be located on another machine to which the user is connected via a network. This is referred to as a client/server configuration, with the user's machine as the client, and the machine housing the data source as the server. The network can be an intranet, which, for example, connects employees within a corporation, or it can be the Internet.

In the three-tier model, commands are sent to a "middle tier" of services, which then sends the commands to the data source. The data source processes the commands and sends the results back to the middle tier, which then sends them to the user. MIS directors find the three-tier model very attractive because the middle tier makes it possible to maintain control over access and the kinds of updates that can be made to corporate data. Another advantage is that it simplifies the deployment of applications. Finally, in many cases, the three-tier architecture can provide performance advantages.
Figure 2: Three-tier Architecture for Data Access.
The DBMS-proprietary protocol provides two-way communication between the database server and the server machine. HTTP, RMI, CORBA or other calls provide two way communication between the server machine and the client machine

Until recently, the middle tier has often been written in languages such as C or C++, which offer fast performance. However, with the introduction of optimizing compilers that translate Java bytecode into efficient machine-specific code and technologies such as Enterprise JavaBeans™, the Java platform is fast becoming the standard platform for middle-tier development. This is a big plus, making it possible to take advantage of Java's robustness, multithreading, and security features.

With enterprises increasingly using the Java programming language for writing server code, the JDBC API is being used more and more in the middle tier of a three-tier architecture. Some of the features that make JDBC a server technology are its support for connection pooling, distributed transactions, and disconnected rowsets. The JDBC API is also what allows access to a data source from a Java middle tier.

Storing image in db using jdbc

Assuming you have a table with a blob field and you want to save a file and store it in the database table or you want to read from a blob object stored in a database, you can use these below java code snippets to write file and read file from database.
The sample table is created as below to have a blob field to store file.


CREATE TABLE t1 (c1 INT PRIMARY KEY NOT NULL, c2 BLOB(5M));


Then use the below code snippet to insert an image file as follows.
 
PreparedStatement pstmt = conn.prepareStatement ("INSERT INTO t1 VALUES (?,?)");
pstmt.setInt (1, 100);
File fBlob = new File ( "image1.gif" );
FileInputStream is = new FileInputStream ( fBlob );
pstmt.setBinaryStream (2, is, (int) fBlob.length() );
pstmt.execute ();
...

 

Retrieving a BLOB or in other words retrieving the image file stored in the database as follows:
 
Statement stmt = conn.createStatement ();
ResultSet rs= stmt.executeQuery("SELECT * FROM t1");
while(rs.next()) {
int val1 = rs.getInt(1);
InputStream val2 = rs.getBinaryStream(2);
...
} rs.close();

sending mail through java

SENDING MAIL THROUGH JAVA
You can use the JavaMail API to send emails from your Java application. Though the JavaMail API allows you to do many things including the ability to retrieve and read the emails or sending emails etc, this sample java program demonstrates how to send email from your Java application. Remember to change the email host (String host) to your email server host, otherwise it won't work. import java.util.*;

import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class SimpleSendEmail {
public static void main(String[] args) {
// Collect the necessary information to send a simple message
// Make sure to replace the values for host, to, and from with
// valid information.
// host - must be a valid smtp server that you currently have
// access to.
// to - whoever is going to get your email
// from - whoever you want to be. Just remember that many smtp
// servers will validate the domain of the from address
// before allowing the mail to be sent.

String host = "server.myhost.com";
String to = "YourFriend@someemail.com";
String from = "Me@myhost.com";
String subject = "My First Email";
String messageText = "I am sending a message using the"
+ " JavaMail API.\n"
+ "Here type your message.";
boolean sessionDebug = false;
// Create some properties and get the default Session.
Properties props = System.getProperties();
props.put("mail.host", host);
props.put("mail.transport.protocol", "smtp");
Session session = Session.getDefaultInstance(props, null);
// Set debug on the Session so we can see what is going on
// Passing false will not echo debug info, and passing true
// will.

session.setDebug(sessionDebug);
try {
// Instantiate a new MimeMessage and fill it with the
// required information.
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] address = {new InternetAddress(to)};
msg.setRecipients(Message.RecipientType.TO, address);
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(messageText);
// Hand the message to the default transport service
// for delivery.
Transport.send(msg);
}
catch (MessagingException mex) {
mex.printStackTrace();
}
}
}