414
Chapter 19: Introduction to Databases and SQL
Database permissions
In many database environments, a database administrator defines the access privileges for users
accessing the database, usually through username and password. When a person attempts to
connect to a database, the database ensures that the username and password are valid and then
imposes access requirements on the user.
Privileges can restrict user access so that a user can do the following:
•
Read data.
•
Read data and add rows .
•
Read data, add rows, modify existing tables.
In ColdFusion MX, you use the ColdFusion MX Administrator to define database connections,
called
data sources
. As part of defining these connections, you specify the username and password
used by ColdFusion to connect to the database. The database can then control access based on
this username and password.
For more information on creating a data source, see
Configuring and Administering ColdFusion
MX
.
Commits, rollbacks, and transactions
Before you access data stored in a database, it is important to understand several database
concepts, including:
•
Commit
•
Rollback
•
Transactions
A database
commit
occurs when you make a permanent change to a database. For example, when
you write a new row to a database, the write does not occur until the database commits the
change.
Rollback
is the process of undoing a change to a database. For example, if you write a new row to
a table, you can rollback the write up to the point where you commit the write. After the commit,
you can no longer rollback the write.
Most databases support transactions where a transaction consists of one or more SQL statements.
Within a transaction, your SQL statements can read, modify, and write a database. You end a
transaction by either committing all your changes within the transaction or rolling back all of
them.
Transactions
can be useful when you have multiple writes to a database and want to make sure all
writes occurred without error before committing them. In this case, you wrap all writes within a
single transaction and check for errors after each write. If any write causes an error, you rollback
all of them. If all writes occur successfully, you commit the transaction.
A bank might use a transaction to encapsulate a transfer from one account to another. For
example, if you transfer money from your savings account to your checking account, you do not
want the bank to debit the balance of your savings account unless it also credits your checking
account. If the update to the checking account fails, the bank can rollback the debit of the savings
account as part of the transaction.
ColdFusion MX includes the
cftransaction
tag that lets you implement database transactions
for controlling rollback and commit. For more information, see
CFML Reference
.
Содержание COLDFUSION MX 61-DEVELOPING COLDFUSION MX
Страница 1: ...Developing ColdFusion MX Applications...
Страница 22: ...22 Contents...
Страница 38: ......
Страница 52: ...52 Chapter 2 Elements of CFML...
Страница 162: ......
Страница 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Страница 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Страница 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Страница 266: ......
Страница 314: ...314 Chapter 14 Handling Errors...
Страница 344: ...344 Chapter 15 Using Persistent Data and Locking...
Страница 349: ...About user security 349...
Страница 357: ...Security scenarios 357...
Страница 370: ...370 Chapter 16 Securing Applications...
Страница 388: ...388 Chapter 17 Developing Globalized Applications...
Страница 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Страница 410: ......
Страница 426: ...426 Chapter 19 Introduction to Databases and SQL...
Страница 476: ...476 Chapter 22 Using Query of Queries...
Страница 534: ...534 Chapter 24 Building a Search Interface...
Страница 556: ...556 Chapter 25 Using Verity Search Expressions...
Страница 558: ......
Страница 582: ...582 Chapter 26 Retrieving and Formatting Data...
Страница 668: ......
Страница 734: ...734 Chapter 32 Using Web Services...
Страница 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Страница 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Страница 788: ......
Страница 806: ...806 Chapter 35 Sending and Receiving E Mail...