Important Notice !!!

This blog has been discarded and no update any more.

Please visit http://www.quantlego.com for active updates.

Sorry for any inconvenience.





Sunday, May 12, 2013

Natural gas reserves in United States

| |
0 comments
Underground Reservoirs Hold Oil and Gas

A "reservoir" is a place where large volumes of methane, the major component of natural gas, can be trapped in the subsurface of the Earth at places where the right geological conditions occurred at the right times.

Reservoirs are made up of porous and permeable rocks that can hold significant amounts of oil and gas within their pore spaces.

What Are Proved Reserves?

Proved reserves of natural gas are estimated quantities that analyses of geological and engineering data have demonstrated to be economically recoverable in future years from known reservoirs.

Proved reserves are added each year with successful exploratory wells and as more is learned about fields where current wells are producing. For this reason those reserves constantly change and should not be considered a finite amount of resources available. Application of new technologies can convert categories of previously uneconomic natural gas resources into proved reserves. U.S. proved reserves of natural gas have increased in every year since 1999, a trend accelerated by shale gas drilling.

How Much Natural Gas Reserves Are in the United States?

In 2010, U.S. natural gas proved reserves, estimated as "wet" gas which includes natural gas plant liquids, increased by 12% to 318 trillion cubic feet (Tcf). Major improvements in shale gas exploration and production technologies drove the increase in U.S. natural gas proved reserves.

What Are Undiscovered Technically Recoverable Resources?

In addition to proved natural gas reserves, there are large volumes of natural gas classified as undiscovered technically recoverable resources. Undiscovered technically recoverable resources are expected to exist because the geologic settings are favorable despite the relative uncertainty of their specific location. Undiscovered technically recoverable resources are also assumed to be producible over some time period using existing recovery technology.

Did You Know?

In 1821, William Hart dug the first well specifically to produce natural gas in the United States in the Village of Fredonia on the banks of Canadaway Creek in Chautauqua County, New York. It was 27 feet deep, excavated with shovels by hand, and its gas pipeline was hollowed-out logs sealed with tar and rags.
Read More

Natural gas imports and exports

| |
0 comments
The United States consumes more natural gas than it produces. While most of the natural gas consumed in the United States is produced domestically, imports from other countries are also an important source of supply. The United States is a "net importer" of natural gas, meaning that it imports more natural gas than it exports.

Reliance on natural gas imports has declined in recent years due to a surge in natural gas production, resulting from more efficient, cost-effective drilling techniques, notably in the production of natural gas from shale formations. Net imports (imports minus exports) of natural gas accounted for 8% of U.S. natural gas consumption in 2011, compared to the 2007 peak of 16%.

Natural gas can be transported in two ways:
  1. Via pipeline — Forty-eight natural gas pipelines, representing approximately 28 billion cubic feet per day of capacity, imports, and exports natural gas between the United States and Canada or Mexico.
  2. Via ship in the form of liquefied natural gas (LNG)
In 2011, 90% of net imports came by pipeline, primarily from Canada, and 10% came by liquefied natural gas (LNG) tankers carrying gas from around the world.

Pipeline Imports of Natural Gas are Mostly from Canada

In 2011, net pipeline imports totaled 1,670 billion cubic feet, or 7% of total natural gas consumption. The United States received almost 90% of its pipeline-imported natural gas from Canada with the remainder from Mexico.

The United States Imports a Small Amount of Liquefied Natural Gas (LNG)

In 2011, LNG imports totaled 349 billion cubic feet, or about 1% of total natural gas consumption. LNG imports from Egypt, Qatar, Trinidad and Tobago, and Yemen contributed about 90%of total LNG imports.

Most Natural Gas Exports Go to Canada and Mexico

Exports of natural gas peaked in 2011, largely due to expanded pipeline exports to Canada and Mexico. Canada accounted for 62% of pipeline natural gas exports, and Mexico accounted for 33%. U.S. exports of natural gas also include:
  • Domestically produced natural gas shipped to Japan as LNG
  • LNG originally imported to the United States that is "re-exported" to new destinations where prices are higher
Read More

Where our natural gas comes from

| |
0 comments
Most of the Natural Gas Consumed in the United States Comes from Domestic Production

U.S. natural gas production and consumption were nearly in balance through 1986. After that, consumption began to outpace production, and imports of natural gas rose to meet U.S. demand for the fuel. Production increased from 2006 through 2011, when it reached the highest recorded annual total since 1973. The increases in production were the result of more efficient, cost-effective drilling techniques, notably in the production of natural gas from shale formations.

Share of 2011 natural gas marketed production:

Texas (29%)
Wyoming (9%)
Federal Offshore Gulf of Mexico (8%)
Louisiana (13%)
Oklahoma (8%)
In 2011, 90% of net imports came by pipeline, primarily from Canada, and 10% came by liquefied natural gas (LNG) tankers carrying gas from five different countries.

What is the Federal Offshore Gulf of Mexico?

Some natural gas and oil wells are drilled into the ocean floor in waters off the coast of the United States. States have jurisdiction over any natural resources within three nautical miles of their coastline, except for Texas and the west coast of Florida where state jurisdiction extends to nine nautical miles. The federal government retains ownership to resources past those limits. There are around 3,400 oil and gas production platforms in federal waters up to roughly 7,500 feet deep and up to 200 miles from shore. Most of them are in the Gulf of Mexico.

What Are Gas Shales?

Shale is a very fine-grained sedimentary rock that is easily broken into thin, parallel layers. Shales can contain a large amount of natural gas, but it's not necessarily mobile. Extensive efforts such as horizontal drilling and creating artificial fractures in the rock are often needed to achieve satisfactory production rates.

Gas shale is one of a number of "unconventional" sources of natural gas; other unconventional sources of natural gas include natural gas produced from coalbeds and from "tight" (impermeable) sandstone or chalk formations.

Supplemental Gas Supplies

Supplemental gas supplies include blast furnace gas, refinery gas, propane-air mixtures, and synthetic natural gas (gas made from petroleum hydrocarbons or from coal). These supplemental supplies totaled 61 billion cubic feet (Bcf) in 2011. The largest single source of synthetic gas is the Great Plains Synfuels Plant in Beulah, North Dakota, where coal is converted to pipeline-quality gas.

Natural Gas Is Stored Underground

There were about 410 active underground storage fields (salt fields, aquifers, or depleted fields) in the United States during 2010. Natural gas is injected into these fields primarily during April through October and withdrawn primarily from November through March during the peak heating season. As of April 2012, the estimated capacity for peak working gas storage was 4,410 Billion cubic feet.
Read More

Liquefied natural gas (LNG)

| |
0 comments
Liquefied natural gas (LNG) is natural gas that has been cooled to about -260°F for shipment and/or storage as a liquid. The volume of the liquid is about 600 times smaller than in its gaseous form. In this compact form, natural gas can be shipped in special tankers to receiving terminals in the United States and other importing countries. At these terminals, the LNG is returned to a gaseous form and transported by pipeline to distribution companies, industrial consumers, and power plants.

Liquefying natural gas provides a means of moving it long distances where pipeline transport is not feasible, allowing access to natural gas from regions with vast production potential that are too distant from end-use markets to be connected by pipeline.

In 2011, LNG imports contributed about 1% of total natural gas consumption. LNG imports from Egypt, Qatar, Trinidad and Tobago, and Yemen contributed about 90% of total LNG imports.

Even though the United States is primarily an importer of liquefied natural gas (LNG), it is also an exporter. Sometimes LNG originally imported to the United States is "re-exported" to new destinations where prices are higher.

Read More

Natural gas pipelines

| |
0 comments
An intricate transportation system, made up of about 1.5 million miles of mainline and other pipelines, links production areas and natural gas markets. The U.S. natural gas transportation network delivered more than 24 trillion cubic feet of natural gas during 2010 to about 71 million customers.

What Makes Up This Transportation Network?

Transporting natural gas from the production field to the consumer involves a series of steps, generally carried out in order:
  • Gathering systems, primarily made up of small-diameter, low-pressure pipelines, move raw natural gas from the wellhead to a natural gas processing plant or to an interconnection with a larger mainline pipeline.
  • Processing plants separate natural gas liquids and impurities from the natural gas stream before the natural gas is delivered into a mainline transmission system.
  • About 306,000 miles of wide-diameter, high-pressure interstate and intrastate transmission pipelines transport natural gas from the producing area to market areas. Compressor stations (or pumping stations), located strategically along the length of the pipeline network, keep the natural gas flowing forward along the pipeline system. More than 200 companies operate mainline transmission pipelines.
  • Underground storage facilities, fashioned from depleted oil, natural gas, or aquifer reservoirs or salt caverns, are used to store natural gas as a seasonal backup supply. In 2007, about 125 natural gas storage operators managed roughly 400 active storage fields. When needed, this reserve is withdrawn to meet additional customer demand during peak usage periods. Aboveground liquefied natural gas storage facilities are also used for this purpose. More than 200 companies operate
  • More than 1,300 local distribution companies deliver natural gas to end users through hundreds of thousands of miles of small-diameter service lines. Local distribution companies reduce the pressure of the natural gas received from the high-pressure mainline transmission system to a level that is acceptable for use in residences and commercial establishments.

How Did This Transmission and Distribution Network Become So Large?

About 142,000 miles of the current 306,000 miles of the mainline natural gas transmission network were installed in the 1950s and 1960s as consumer demand for low-priced natural gas more than doubled following World War II. In fact, about half of the natural gas pipeline mileage currently installed in Texas and Louisiana, two of the largest natural gas production areas in the country, was constructed between 1950 and 1969. By the close of 1969, marketed natural gas production exceeded 20 trillion cubic feet for the first time.

A large portion of the 1.2 million miles of local distribution pipelines, which receive natural gas from the mainline transmission grid and deliver it to consumers, was also installed during the same period. However, the period of greatest local distribution pipeline growth has been more recent. In the 1990s, more than 225,000 miles of new local distribution lines were installed to provide service to the many new commercial facilities and housing developments that wanted access to natural gas supplies during that period of economic growth.

The demand for natural gas has grown in recent years in part because it is considered a relatively environmentally-friendly energy source. Its use as an electric power generation fuel also has grown steadily with a decline in the capital costs of producing electric power from natural gas as technology in the area has improved.

Natural gas prices, along with oil prices, increased substantially between 2003 and 2008. Higher prices gave natural gas producers the incentive to expand development of new natural gas fields. Consequently, new pipelines have been and are being built to link these new production sources to the existing mainline transmission network. Construction of new transmission and local distribution mainline pipeline mileage during the current decade, 2000-2009, is projected to surpass that of any other decade since the 1950s.

Read More

Delivery and storage of natural gas

| |
0 comments
Natural Gas Is Often Stored Before It Is Delivered

Natural gas is moved by pipelines from the producing fields to consumers. Because natural gas demand is greater in the winter, it is stored along the way in large underground storage systems, such as old oil and gas wells or caverns formed in old salt beds. The gas remains there until it is added back into the pipeline when people begin to use more gas, such as in the winter to heat homes.

Storage of natural gas

When the gas gets to the communities where it will be used (usually through large pipelines), it flows into smaller pipelines called "mains." Very small lines, called "services," connect to the mains and go directly to homes or buildings where it will be used.

Natural Gas Can Also Be Stored and Transported as a Liquid
LNG Transport Barge Unloading
When chilled to very cold temperatures, approximately -260°F, natural gas changes into a liquid and can be stored in this form. Because it takes up only 1/600th of the space that it would in its gaseous state, liquefied natural gas (LNG) can be loaded onto tankers (large ships with several domed tanks) and moved across the ocean to other countries. When this LNG is received in the United States, it can be shipped by truck to be held in large chilled tanks close to users or turned back into gas when it's ready to put in the pipelines.
Read More

Formation and extrapolation of natural gas

| |
0 comments
How Was Natural Gas Formed?

The main ingredient in natural gas is methane, a gas (or compound) composed of one carbon atom and four hydrogen atoms. Millions of years ago, the remains of plants and animals (diatoms) decayed and built up in thick layers. This decayed matter from plants and animals is called organic material — it was once alive. Over time, the sand and silt changed to rock, covered the organic material, and trapped it beneath the rock. Pressure and heat changed some of this organic material into coal, some into oil (petroleum), and some into natural gas — tiny bubbles of odorless gas.


How Do We Get Natural Gas?

The search for natural gas begins with geologists, who study the structure and processes of the Earth. They locate the types of rock that are likely to contain gas and oil deposits.

Today, geologists' tools include seismic surveys that are used to find the right places to drill wells. Seismic surveys use echoes from a vibration source at the Earth’s surface (usually a vibrating pad under a truck built for this purpose) to collect information about the rocks beneath. Sometimes it is necessary to use small amounts of dynamite to provide the vibration that is needed.

Scientists and engineers explore a chosen area by studying rock samples from the earth and taking measurements. If the site seems promising, drilling begins. Some of these areas are on land but many are offshore, deep in the ocean. Once the gas is found, it flows up through the well to the surface of the ground and into large pipelines.

Some of the gases that are produced along with methane, such as butane and propane (also known as "by-products"), are separated and cleaned at a gas processing plant. The by-products, once removed, are used in a number of ways. For example, propane can be used for cooking on gas grills.

Natural gas withdrawn from a well may contain liquid hydrocarbons and nonhydrocarbon gases. This is called "wet" natural gas. The natural gas is separated from these components near the site of the well or at a natural gas processing plant. The gas is then considered "dry" and is sent through pipelines to a local distribution company, and, ultimately, to the consumer.

Dry natural gas is also known as consumer-grade natural gas. In addition to natural gas production, the U.S. gas supply is augmented by imports, withdrawals from storage, and by supplemental gaseous fuels.

Most of the natural gas consumed in the United States is produced in the United States. Some is imported from Canada and shipped to the United States in pipelines. A small amount of natural gas is shipped to the United States as liquefied natural gas (LNG).

We can also use machines called "digesters" that turn today's organic material (plants, animal wastes, etc.) into natural gas. This process replaces waiting for millions of years for the gas to form naturally.

Did You Know?

Because natural gas is colorless, odorless, and tasteless, mercaptan (a chemical that smells like sulfur) is added before distribution, to give it a distinct unpleasant odor (it smells like rotten eggs). This added smell serves as a safety device by allowing it to be detected in the atmosphere, in cases where leaks occur.
Read More

Saturday, May 11, 2013

Anatomy of natural gas market in United States

| |
0 comments
Note: This article is extracted from the book: Book name, Author, Publisher, Year.

The United States natural gas market can be divided into following sub-regions:

Western Gas Region

  • Electrical generators through out this entire region depend on natural gas as a primary fuel. In summers it is very hot, and natural gas is especially in demand then to provide electricity for air-conditioning.
  • The major competing power source is hydroelectric power from the Pacific Northwest. As a result, precipitation and snowmelt can have a large effect on regional natural gas prices during peak demand periods.
  • Most of region has mild winters.
  • In the Western United States, the geography is dominated by the Rocky Mountains. The West Coast (Washington, Oregon, California) and parts of Arizona are heavily populated. However, most of the region has a sparse population. California is the biggest user of natural gas, and tradding commonly revolves around imports to the California market. These imports come from Canda and the Desert Southwest.
  • Storage capacity is extremely limited. This can lead to sharp price movements during the period of peak demand.
  • Western basis prices are not highly correlated with the NYMEX futures (Henry Hub) since the region does not directly import from the Gulf Coast, where Henry Hub is located.
  • A substantial amount of natural gas is produced at the eastern edge of the Rocky Mountains in Wyoming, Utah, and Colorado. However, most of this gas flows to the Midwest rather than to the population centers on the West Coast.


MidWestern Gas Region

  • The Midwestern is a major consuming region during winter months. Cold winters characterize the entire Midwest region and there is a strong seasonal demand for natural gas in the winter to provide residential heating.
  • This region does not use natural gas as a primary fuel for electrical power plants. Coal is the primary fuel for power in the Midwest. There is comparatively little demand for natural gas in the summer months.
  • Numerous storage facilities and extensive local distribution networks are located in the region. Many of these areas have gonernment mandated obligations to meet residential demand during winter months. For example, to ensure that consumers have access to fuel, government might force gas in storage facilities to be delivered to residential consumers rather than saving it for commercial use.
  • Large pipelines connect the Midwest to all of the major supply basins in North America. Canada and the Rocky Mountains supply the bulk of the Midwest's natural gas requirements. However, some gas also comes from the Gulf Coast region when it is available.
  • Basis prices in the Midwest are somewhat correlated with NYMEX futures (Henry Hub). The region imports gas from the Golf Coast, but also has access to other gas supplies.


Eastern Gas Region

  • On the East Coast, natural gas is used extensively for both residential heating and electrical generation. As a result, there is a year-around demand for natural gas in this region.
  • There is a limited amount of storage available in the region. Combined with the high seasonal demand for both heating and electricity in the winter, basis prices (prices relative to the supply regions) are often the highest in the country.
  • LNG (liquefied natural gas) terminals are being built to import gas from other countries and provide additional storage.
  • The East Coast is a heavy importer of natural gas from Gulf Coast region. As a result, basis prices are highly correlated with NYMEX futures (Henry Hub).


Texas and Gulf Gas Region

  • The Texas/Gulf Coast region is a net exporter of natural gas. It is the most important natural gas producing region in North America. Most of the exports flow to the East Coast and the industrialized Midwest.
  • Abundant local supplies have made the region heavily dependent upon natural gas as a fuel for electricity generation.
  • The region has mild winters, and there is a limited seasonal demand for natural gas during winter months for heating.
  • There is a substantial amount of storage in the region. This helps processing plants located in the Gulf Coast region balance their production with consumer demand from other parts of the country.
  • The basis prices in the region are highly correlated to NYMEX future prices. The settlement location for NYMEX futures, Henry Hub, is located in western Louisiana.


Southeast Gas Region

  • Natural gas is primarily used to provide electricity in the Southeastern United States. The demand for electricity peaks during summer months as the hot summer create high demand for air conditioning.
  • Mild winters limit the need for seasonal residential heating.
  • The Southeast region has very limited or no storage capacity.
  • LNG (liquefied natural gas) terminals are being constructed to supply additional natural gas and provide storage facilities. There is a major LNG terminal at Elba Island.
Read More

Overview of natural gas market

| |
0 comments
The natural gas market is one of the largest, most established energy markets.
  1. Natural gas plays a central role in the energy industry
    • Cleaner burning than coal, less expensive than petroleum, limited carbon emissions, operational flexibility and efficiency.
    • Almost all of fossil-fuel-based power plants built in USA since 1990 can burn natural gas ==> strong link between power and natural gas prices.
    • It is prohibitively expensive to replace existing infrastructures of gas pipelines ==> Heating and electricity in North America highly depend on natural gas.
  2. Composition of natural gas
    • Nonrenewable fossil fuel, colorless, odorless gas
    • Primary composition: methane (CH4)
    • Other contained hydrocarbons such as ethane (C2H6), propane (C3H8), and butane (C4H10)
    • 'Dry' ==> Almost pure methane; 'Wet' ==> contains substantial amounts of other hydrocarbons.
  3. Trading unit of natural gas
    • Natural gas is commonly traded in units of heat energy like British Thermal Units (BTUs), rather than in units of volume (like cubic feet)
    • One cubic foot of dry natural gas contains approximately 1,000 BTUs
    • 1 MMBTUs (million BTUs) = 1,000,000 BTUs ==> 1 BCF (billion cubic feet) natural gas contains about 1 million MMBTUs
    • Natural gas are typically sold to consumers in units of therms. 1 therm = 100,000 BTUs = 0.1 MMBTUs
  4. Heat density
    • One gallon (=0.13 cubic feet) gasoline contains 124,000BTU, the amount of heat contained in 100 cubic feet natural gas ==> 1 cf gasoline ~ 770 cf natural gas
    • 1 cf gasoline ~ 3 cf natural gas (under 250 atmosphere pressure)
    • 1 gallon gasoline ~ 1.5 gallon natural gas (supercooled liquid
  5. Transportation
    • Natural gas is transported through pipelines, instead of pressurized container because it contains relatively low amount of energy per volume
    • Natural can also be cooled to -260 F (liquefaction) to be transported in liquid form, suitable for the cases where building pipelines is impractical, such as transportation over oceans.
  6. Pipeline Transportation
    • Hub --- the location where two or more pipelines connect
    • Citygate --- a special type of hub where interstate pipelines connect to local distribution networks.
  7. Basis trading
    • To trade natural gas, traders usually enter into two trades: (1) a futures trade at the Henry Hub; (2) a basis swap that exchanges the Henry Hub exposure for an exposure at some other location.
    • Natural gas futures (Henry Hub contracts) are standardized, liquid, and traded at exchange
  8. Trading types
    Since natural gas prices show strong seasonality, it is not common for traders to play directional bet on the entire natural gas market. Generally, traders speculate on one aspect of the natural gas market by entering into spread trades, where a trader benefits from the price difference between securities by buying one and selling another.
    • Location spreads: price difference between two locations
    • Heat rates: speculate the relation between natural gas and electricity prices
    • Time spreads: speculate on the price difference between periods of high and low demand
    • Swing trades: traders use their gas storage capabilities to play the buy-low-sell-high games.
  9. Spot vs forward markets
    • Natural gas spot prices are heavily influenced by weather
    • Natural gas forward prices are seasonally cyclical
    • The spot market is substantially more volatile than the forward market
    • Natural gas futures prices are not linked to spot prices and carrying costs in the same way that the futures prices for stocks, bonds, and gold are linked to their spot prices.
Read More

Wednesday, April 24, 2013

Import data from Microsoft SQL server to Matlab using JDBC driver

| |
0 comments
Since Matlab Visual Query Builder is a simple tool mainly for testing purpose, it is not recommended for setting up database connection within Matlab. This article talks about how to use Matlab Database toolbox functions to set up a connection to Microsoft SQL server database.

Environment
  • Windows 7, 64-bit
  • Matlab R2012a
  • Microsoft SQL Server 2008
Installation
  1. Download JDBC driver from Microsoft and install it so that Matlab is able to interact with SQL Server database via the Java interface.
    • You can install the driver to a local folder, such as
      C:\Program Files\Microsoft SQL Server JDBC Driver 3.0
  2. Insert the path of the database driver JAR file in the classpath.txt file
    • The path file is located in the Matlab installation folder, such as
      C:\Program Files\MATLAB\R2012a\toolbox\local\classpath.txt
    • A quick way to edit the path file is to run Matlab command:
      open('classpath.txt')
    • Add the following line to the end of the file:
      C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\sqljdbc4.jar
  3. Insert the path to the folder containing sqljdbc_auth.dll in the librarypath.txt file
    • The path file is located in the Matlab installation folder, such as
      C:\Program Files\MATLAB\R2012a\toolbox\local\librarypath.txt
    • A quick way to edit the path file is to run Matlab command:
      open('librarypath.txt')
    • Add the following line to the end of the file:
      C:\Program Files\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x64
      Note: The path entry should not include the file name sqljdbc_auth.dll.
    • The sqljdbc_auth.dll file is installed in the following location:
      [installation]\sqljdbc_[version]\[language]\auth\[arch]
      where [installation] is the installation directory of the SQL server driver.
      • If you are running a 32-bit Java Virtual Machine (JVM), use the sqljdbc_auth.dll file in the x86 folder, even if the operating system is the x64 version.
      • If you are running a 64-bit JVM on a x64 processor, use the sqljdbc_auth.dll file in the x64 folder.
      • If you are running a 64-bit JVM on a IA-64 processor, use the sqljdbc_auth.dll file in the IA64 folder.
  4. Edit startup.m and add the following line to the end of the file:
    setdbprefs('DataReturnFormat','structure')
    • If you don't have a startup.m file, create one in your default Matlab directory:
      C:\users\user_name\Documents\MATLAB\
  5. Notes:
    • If Matlab refuses to save these files, you may have to restart Matlab using Run as administrator and try again
    • Use path command to check whether following directories has been added to Matlab
      C:\Program Files\MATLAB\R2011a\toolbox\database\database
      C:\Program Files\MATLAB\R2011a\toolbox\database\dbdemos
      C:\Program Files\MATLAB\R2011a\toolbox\database\vqb
      If they aren't, type following commands to add them:
      addpath('C:\Program Files\MATLAB\R2011a\toolbox\database\database','-end');
      addpath('C:\Program Files\MATLAB\R2011a\toolbox\database\dbdemos','-end');
      addpath('C:\Program Files\MATLAB\R2011a\toolbox\database\vqb','-end');
Usage
  • Use database function to connect to a MS SQL Server database, using following syntax
    conn = database(instance, username, password, driver, databaseurl)
    where the arguments, for connecting to MS SQL server with JDBC, are:
    • Instance --- the name of the database, specified as a string
    • username --- User name required to access database, specified as a string. If no user name is required, specify empty strings, ''.
    • password --- Password required to access database, specified as a string. If no password is required, specify empty strings, ''.
    • driver --- JDBC driver name, specified as a string. This is the name of the Java driver that implements the java.sql.Driver interface.
      For MS SQL server: JDBC Driver = com.microsoft.sqlserver.jdbc.SQLServerDriver
    • databaseurl --- Database connection URL, specified as a string. This is a vendor-specific URL that is typically constructed using connection properties like server name, port number, database name, and so on.
      For MS SQL server, database URL = jdbc:sqlserver://localhost:port;database=databasename
      Note: 1433 is a commonly used default port number.
  • One example of Matlab code
    % Make connection to database using JDBC driver.
    conn = database('MARKET_DATA_NYMEX','username','password', …
    'com.microsoft.sqlserver.jdbc.SQLServerDriver', …
    'jdbc:sqlserver://111.22.333.44:1433;database=MARKET_DATA_NYMEX');
     
    % Read data from database.
    e = exec(conn,'SELECT * FROM TableName');
    setdbprefs('DataReturnFormat','cellarray')
    e = fetch(e);
    close(e)
     
    % Assign data to output variable.
    Exciting_Data = e.Data;
     
    % Close database connection.
    close(conn)
Read More
Powered by Blogger.