Back to Coldfusion
JDBCQuery
This
Coldfusion Custom Tag uses JDBC to connect to a
SQL server, to an
Access file, to a
Text file or to an
Excel file without a DSN (
dsnless) in the
Coldfusion Administrator.
Download JDBCQuery
If connecting to an
Access database we need:
- DBFile: The name of the Access Database File. (Required)
- Name: The name of the query to return. (Required)
If connecting to an
Excel file we need:
- DBFile: The name of the Excel File, the connection to an Excel file is READONLY. (Required)
- Name: The name of the query to return. (Required)
If connecting to a
Text file we need:
- DBDir: The absolute path to the dir that contains the text files (asc, csv, tab or txt), the connection to a Text file is READONLY. (Required)
- Name: The name of the query to return. (Required)
If connecting to a
SQL server we need:
- SQLServer: The address of the SQL server to connect to. (Required)
- SQLServerPort: The SQL server port to connect to. (Default 1433)
- Database: The name of the database on the SQL Server. (Required)
- User: The user to login to the database. (Required)
- Password: The password to login to the database. (Required)
- Name: The name of the query to return. (Required)
Access Example:
<cf_JDBCQuery Name="theQueryMDB" DBFile="#expandPath('./')#/AccessDB.mdb">
select top 5 * from Photos
</cf_JDBCQuery>
Text Example:
<cf_JDBCQuery Name="theQueryTxt" DBDir="#expandPath('./')#/">
select top 5 * from theDB.txt
</cf_JDBCQuery>
Excel Example:
<cf_JDBCQuery Name="theQueryXLS" DBFile="#expandPath('./')#/ExcelDB.xls">
select top 5 * from [Sheet1$]
</cf_JDBCQuery>
SQL Example: -- Define here the nedded parameters.
<cf_JDBCQuery Name="theSQLQuery" SQLServer="127.0.0.1" Database="YourDatabase"
user="USER" password="PASSWORD">
select top 5 * from theTable
</cf_JDBCQuery>