Google Answers Logo
View Question
 
Q: Coldfusion datasource ( No Answer,   1 Comment )
Question  
Subject: Coldfusion datasource
Category: Computers > Programming
Asked by: wynandkui-ga
List Price: $2.00
Posted: 20 Dec 2005 01:06 PST
Expires: 19 Jan 2006 01:06 PST
Question ID: 607824
is it possible to create a datasource connection by just using cf
script if i donot have access to the control panel?
Answer  
There is no answer at this time.

Comments  
Subject: Re: Coldfusion datasource
From: cfsynergydotcom-ga on 17 Jan 2006 13:44 PST
 
from: http://www.hostmysite.com/support/cfusion/dsnless/

How do I create a DSNless connection to a database?

The following article explains how to create a DSNless connection to a
database. DNSless connections are direct connections to a database
that do not require a ColdFusion Administrator to make specific
configurations. A DSNless connection can be used to connect to any
type of database, including Microsoft SQL and Microsoft Access.

To create a DSNless connection, add the following snippet of code
within your application.cfm page or to each individual page that
should connect to a database:

<cfscript>

classLoader = createObject("java", "java.lang.Class");
classLoader.forName("sun.jdbc.odbc.JdbcOdbcDriver");
dm = createObject("java","java.sql.DriverManager");

con = dm.getConnection(connection string);

st = con.createStatement();
rs = st.ExecuteQuery("Select * FROM table");
q = createObject("java", "coldfusion.sql.QueryTable").init(rs);

</cfscript>
 

The connectionstring will depend on the type of connecting database.
The following are two common connectionstring examples:

Microsoft SQL

"jdbc:odbc:DRIVER={SQL Server};Database="dbname";Server=192.168.0.0;",
"login", "password"

Microsoft Access

"Driver={Microsoft Access Driver
(*.mdb)};Dbq=C:\websites\folder\mydatabase.mdb;Uid=;Pwd=;"

Note: If you use either of the above examples, you will need to change
the information to refer to your database.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy