Software Package java. SQL

Source: Internet
Author: User
Software Package java. SQL

Provides APIs that use the javatm programming language to access and process data stored in a data source (usually a relational database.

Java. SQL
Interface driver
public interface Driver
 

The interface that each driver class must implement.

The Java SQL framework allows multiple database drivers.

Each driver should provide a class that implements the driver interface.

Drivermanager will try to load as many drivers as it can find, and then, for any given connection request, it will let every driver try to connect to the target URL in sequence.

We strongly recommend that each driver class be small and independent, so that you can load and query the driver class without introducing a large amount of code.

When loading a driver class, it should create its own instance and register the instance with drivermanager. This means that you can call the following program to load and register a driver.

   Class.forName("foo.bah.Driver")
Java. SQL
Interface connection
public interface Connection
 

Connection (session) to a specific database ). Execute the SQL statement in the connection context and return the result.

ConnectionThe object database can provide information to describe its tables, supported SQL syntax, stored procedures, and the function of this connection. This information is used
getMetaDataMethod.

Note:By default,Connection
The object is in the automatic submission mode, which means that it will automatically submit changes after each statement is executed. If the automatic submission mode is disabled, it must be explicitly called to submit changescommit
Method; otherwise, the database changes cannot be saved.

Created using the JDBC 2.1 core APIConnection
The object has a type ing table associated with it that is initially empty. You can enter a custom ing for the UDT in the ing table of this type. In use
ResultSet.getObjectWhen you retrieve a UDT from a data source,getObject
The method checks the type ing table of the connection to check whether there are items that should be udts. If yesgetObjectThe UDT
Maps to the indicated class. If no value exists, the UDT is mapped using the standard ing relationship.

You can create a new type ing table, which isjava.util.Map
Object, you can create an item in it, and pass the item tojava.sql
Method. In this case, This method uses the given type ing table instead of the ing table associated with the connection.

For example, the following code snippet specifies the SQL typeATHLETESWill be mapped to the Java programming language
AthletesClass. The code snippet isConnectionObjectcon
Obtain the type ing table, insert some items in it, and then use the new item to set the type ing table to the connected type ing table.

      java.util.Map map = con.getTypeMap();      map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));      con.setTypeMap(map);


 

Java. SQL
Drivermanager
java.lang.Object  java.sql.DriverManager
public class DriverManager
Extends object
 

Manage basic services of a group of JDBC drivers.
Note:DataSourceThe interface is JDBC 2.0 API
And provides another method to connect to the data source. UseDataSourceObjects are the preferred method to connect to the data source.

As part of initialization,DriverManagerClass will try to load in "JDBC. Drivers"
The driver class referenced in system properties. This allows users to customize the JDBC driver used by their applications. For example ~ /. Hotjava/Properties
File, you can specify:

 jdbc.drivers=foo.bah.Driver:wombat.sql.Driver:bad.taste.ourDriver 

The program can also explicitly load the JDBC driver at any time. For example, my. SQL. Driver is loaded using the following statement:

 Class.forName("my.sql.Driver"); 

Before callinggetConnectionMethod,DriverManager
It will try to find the appropriate driver from the drivers loaded during initialization and those loaded explicitly using the same class loaders as the current applet or application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.