Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

database username/password

Explorer ,
Nov 03, 2010 Nov 03, 2010

Hi,

I have a website and am using coldfusion and  dreamweaver.  My hosting service requires that, in order to access the  database, you must define a username and password in the code.  Its  working online, but in order to get it working on my localhost I have to  delete the username and password from the code.  Is there some way I  can make my localhost need to access the database with the same username  and password my hosting service requires?  It's a pain having to work  on a page and constantly switch between no username and password to a  defined username and password in the code.

1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 03, 2010 Nov 03, 2010

Set the user/pass as a global variable (application scope should be fine)

and use cfif statement in application.cfc or application.cfm to check if you

are using local host or live site. Then set the variable to the right

datasource name, user and pass.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Nov 03, 2010 Nov 03, 2010

You could modify the dsn on your local installation so that it DOES require a username and password.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2010 Nov 04, 2010

sorry, but I don't know what DSN is... can you give me a little explanation?  And where would I have to go/what would I have to do to change it so it DOES require a username and password every time?  In the coldfusion administrator?  In the coldfusion administrator, It looks like my database  defaults to username: root and password: [blank].  I think I tried changing those to the username and password that my site has for my hosting service, but I don't think that worked.  Should it have worked?  I do want to make it so it does require a password.

I would also like to try using application.cfc and do the cfif statement in it, but the way I have my code, it wants to ask for the username and password every time it wants to access the database. that's why I'd like to just have the username and password required on my localhost as well as my hosting service... because i'm not sure how to do the cfif statement in application.cfc because each page requires something like the bit of my code below.  (I would still prefer to just have the localhost require the same username and password for accessing the database, though)

<cfquery name="rsBookReview" datasource="mymindsnotrighttest" username="mikewycklendt" password="password">
SELECT *
FROM books
WHERE book_id = <cfqueryparam value="#URL.book_id#" cfsqltype="cf_sql_numeric">
</cfquery>
<cfquery name="Recordset1" datasource="mymindsnotrighttest" username="mikewycklendt" password="password">
SELECT *
FROM book_comments
WHERE book_id = <cfqueryparam value="#URL.book_id#" cfsqltype="cf_sql_numeric">
ORDER BY book_comment_id ASC
</cfquery>
<cfquery name="Recordset2" datasource="mymindsnotrighttest" username="mikewycklendt" password="password">
SELECT *
FROM book_comments
WHERE book_id = <cfqueryparam value="#URL.book_id#" cfsqltype="cf_sql_numeric">
ORDER BY book_comment_id ASC
</cfquery>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2010 Nov 04, 2010

DSN is an abbreviation for "ColdFusion data source". You can embed a username and password within the data source, or within the CFQUERY tags directly. If you embed them within the CFQUERY tags as you're doing, you can use variables that you'd set in Application.cfc/Application.cfm. In CF 9, you can also set them as properties within the application directly, which is kind of neat. That way, you could use one set of credentials in development, and another in production.

Dave Watts, CTO, Fig Leaf Software

http://www.figleaf.com/

http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on

GSA Schedule, and provides the highest caliber vendor-authorized

instruction at our training centers, online, or onsite.

Read this before you post:

http://forums.adobe.com/thread/607238

Dave Watts, Eidolon LLC
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2010 Nov 04, 2010

If I go into the coldfusion 8 administrator, and go to the '

page, if I change the username and password from username: root password: [blank] to the username and password my hosting service requires (and the username and password that is already defined in my code for each individual query) should that work?

or in the Advanced settings on that same page, does Validation Query or Connection String have anything to do with what I'm trying to do?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 04, 2010 Nov 04, 2010

Yes those fields in the Administrator Data Source form are equivalent to the username and password parameters of the <cfquery...> tag.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2010 Nov 04, 2010

can't believe it was that easy

thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Nov 04, 2010 Nov 04, 2010
LATEST

wycks wrote:

can't believe it was that easy


That is what ColdFusion excels at - at least 80% of the time.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources