CFTRY
I'm curious why with this:
<cftry>
<cfquery name="AddRequest" datasource="SB">
insert into inforeq
(Cust_Name, Cust_Address, Cust_Address2, Cust_City,
Cust_State,
Cust_Zip, Cust_Email, Cust_MailInfo, Cust_Events, Cust_Class,
Cust_Info_Sent, Cust_Newsletter,Cust_Beg_Class, Cust_Lat,
Cust_Long)
values
(<cfqueryparam cfsqltype="cf_sql_varchar"
value="#CapFirstTitle(strName)#">,<cfqueryparam
cfsqltype="cf_sql_varchar"
value="#CapFirstTitle(arguments.Address1)#">,<cfqueryparam
cfsqltype="cf_sql_varchar"
value="#CapFirstTitle(new_Address2)#">,<cfqueryparam
cfsqltype="cf_sql_varchar"
value="#CapFirstTitle(arguments.City)#">,<cfqueryparam
cfsqltype="cf_sql_char"
value="#ucase(arguments.State)#">,<cfqueryparam
cfsqltype="cf_sql_varchar"
value="#arguments.Zip#">,<cfqueryparam
cfsqltype="cf_sql_varchar" value="#arguments.Email#">,
<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.Info#">,<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.Events#">,<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.Class#">,<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.Info_Sent#">,<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.News#">,<cfqueryparam
cfsqltype="cf_sql_integer"
value="#arguments.Beg_Class#">,#mylat#,#mylng#)</cfquery>
<cfcatch type="database">
<cfset session.dbResult="#cfcatch.SQLState#">
<cflocation url="../test101.cfm" addtoken="no">
</cfcatch>
</cftry>
I'm not getting a result for #cfcatch.SQLState# ?? When I
output the value
of session.dbResult, its N/A.......
This is on a MySql database..... if that helps
It should be, I changed the datasource to something that
didn't exist
"Adam Cameron" <[email protected]> wrote in message
news:1pufm20vo2uio.1izkqkkqhpsbn$.[email protected]..
>> I'm curious why with this:
>>
>> <cftry>
>> <cfquery name="AddRequest" datasource="SB">
> [...]
>>
value="#arguments.Beg_Class#">,#mylat#,#mylng#)</cfquery>
>> <cfcatch type="database">
>> <cfset session.dbResult="#cfcatch.SQLState#">
>> <cflocation url="../test101.cfm"
addtoken="no">
>> </cfcatch>
>> </cftry>
>>
>> I'm not getting a result for #cfcatch.SQLState# ??
When I output the
>> value
>> of session.dbResult, its N/A.......
>>
>> This is on a MySql database..... if that helps
>
> Well... is the query actually erroring?
>
> --
> Adam
Similar Messages
-
Catching java.lang.NullPointerException with cftry/cfcatch?
I'm getting a java.lang.NullPointerException returned on an
update function in a CFC:
"The cause of this output exception was that:
java.lang.NullPointerException."
I want to find where it's generating this error so I can fix
it. I've never really used CFTRY and CFCATCH, but figured now would
be a good time to learn if this helped me track down the null. Can
anyone provide an example of how to use these tags with the above
NPE and output a message that give info on where it's faulting?
I'm using a standard update query,
<cfquery>
UPDATE table
SET columns = new values
WHERE ID column = some ID
</cfquery>That was a great tip Dan. Helped me find the line. Apparently
a datatype "date" was given an incorrect null value. I figured the
problem and the update works now :)
Here's code incase someone wants to know: -
Coldfusion Error catching (cftry cfcatch) best practice question...
Hey all -
I wanted to get a couple of opinions about this. Obviously I want to catch any and all errors that hit my server and avoid exposures to my end users, but I didnt know what the most efficient way of doing such was. Does it make sense to put a cftry cfcatch around the entirety of my code on every page? (I use a lot of embeds...cfinclude) Or is that too broad? How does that effect performance? Is there another way to auto catch and email all errors and then show the user a custom error page? I searched around, but I got bits and pieces based on specific requests...not really any "best practice" tips. Any suggestions would be fantastic.
Thanks much!There are no real best practices as such, as it's largely down to your application. The only real "standard" is the onError() method in Application.cfc, which will handle any Exceptions which make their way to it - i.e. any that are not caught by an explicit try/catch block.
When considering what you are now, I consider this: where do I want to display an error? How far down the line does it matter? There's no right or wrong answer, it's down to you.
Say you're displaying a page, which is made up of ten includes. If there's an error in one, do you want the other nine displayed, or do you want the whole page to error? If it's the former, wrap each one in its own try/catch. If it's nonsensical to do so, just let the page throw an Exception to get picked up by your Application.onError() method.
It also depends largely on whether or not an error is "recoverable" - is it of any use telling someone that a small but important part of the page failed becuase of a database issue? Probably not. There's nothing they can do about it, so just throw an error and let your error template sort it out.
It also depends on the context in which the page is being called - if it's an Application with users, you can display an error page with as much or as little information as you want. If it's a remote CFC call, however, it's extremely annoying for the remote developer to just get useless ColdFusion exceptions. Therefore I would always wrap every remote CFC method in its own try/catch, so if something goes wrong you can still return them something useful - even a "false" is better sometimes than an exception. You can then do what you like within the catch block - send you an email, log to disk, whatever.
Just a few thoughts, haven't proof read them though so expect massive, glaring mistakes and poor advice. -
Looping through email addresses. CFTRY/CFCATCH
I am building an email system that will be looping through a
list of email addresses in our database and sending mail via
CFMAIL. Alot of times, the email addresses are bad. i.e.: no
".com", a comma in the email address, bad characters etc. How can I
loop through the email addresses sending them out, but when CFMAIL
errors out because of a bad address, the loop continues on ignoring
the bad address. Can I do this with CFTRY/CFCATCH? Will
CFTRY/CFCATCH halt the process entirely or will it catch it then
continue on?Cold Fusion has an isvalid function you can use to confirm
that any
given string is a properly formatted email address. You can
use this to
prevent improperly formatted addresses from getting into your
db in the
first place.
If ColdFusion was used to put the email address into the
database in the
first place. That is not always true. Some places have more
the one
application working with a given database.
Now using isValid to validate the address before attempting
to use it in
a <cfmail...> tag may provide some value, but would
still be comfortable
with wrapping the tag with a try catch. I just like to do so
whenever I
am playing with other protocols. -
CFTransaction/CFCatch/CFTry
I have an insert query that parses a large text file into a query object and then loops through it and inserts it into a data table.
However sometimes there are bad values are in the text file...like a text value where a date should be etc. or a nonnumeric value where a numeric should be..... This causes the loo/ insert query to STOP.
If I get all good values I want the data to be inserted and have processing continue.
However If I get a bad value in the file I want all processing to stop and all of the prior inserted rows to be deleted and I want to get an error message emailed to me
How do I do this?
Here is the Cfloop and the insert query below..again the problem is that if I get a bad value I want processing to stop and the data table to rollback to the initial state prior to any processing.....and I want an email alerting me there was an issue ( I know how to use CFMAIL)
<cftransaction>
<cfloop query="stocks">
<CFQUERY name="load_the_data" datasource="abc" >
INSERT INTO portfolios_new (portfolio , portfolio_ID , load_date , ticker , cusip,BC1, BC1_ID , BC2 , BC2_ID , BC3 , BC3_ID, Load_ID)
VALUES ('#Portfolio#'
,'#PORTFOLIOID#','#loadDate#','#Ticker#','#Cusip#','#BC1#','#BC1Id#','#BC2#','#BC2Id#','# BC3#','#BC3Id#', '#next_load_id#' );
</CFQUERY>
</cfloop>
</cftransaction>Dave,
I am going to look into this : That said, why not check the values as you're reading them in the first place? That way, you can avoid writing the rows to the database if there's a bad one.
But on this below...I guess instead of , I'd need to know if there was any kind of error.
Isn't there a way to do a cfif to see if there is any type of database error...or any kind of error for that matter
What would that CFIF look like?
<cfif >
Patrick Hutchinson
www.1design.com
Office: 804-360-0695
Cell: 804-370-6873
Email: [email protected] -
How to handle Coldfusion SOAP Web Service Errors
Hi,
I have just created simple wsdl example:
My Component:
<cfcomponent displayname="mytest">
<cffunction name="service_login_authentication" access="remote" output="true" returntype="any" hint="Returns login">
<cfargument name="login" type="string" required="yes">
<cfargument name="password" type="string" required="yes">
<cfif #arguments.login# eq "abcdef" and #arguments.password# eq "123456">
<cfxml variable="soapRes">
<kps_response>
<message>OK</message>
<token>354dfdffsdf</token>
</kps_response>
</cfxml>
<cfelse>
<cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />
</cfif>
<cfreturn soapRes >
</cffunction>
</cfcomponent>
Its generating wsdl and no problem with response but when generating any error like username and password does not match then it's generating fault code like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.CustomException : INVALID LOGIN. ]</faultstring>
<detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">HOST_NAME</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
But I want customize Fault Code like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<faultcode>1000</faultcode>
<faultstring>INVALID LOGIN</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
Fault Code and Fault String should be customize and I don't want detail tag completely. In old ColdFusion version like ColdFusion 8 displaying detail tag with <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/"> coldfusion.xml.rpc.CFCInvocationException: and so on.
Any suggestions on how to create customize faultcode and faultstring is very helpful.
Thanks!!But my component is not produces this fault code:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<<faultcode>1000</faultcode>
<faultstring>INVALID LOGIN</faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
What is your ColdFusion Version as i have checked in ColdFusion 11 developer edition and ColdFusion 8 enterprise which is on window 2003 server.
Could you please check my below component, did i am doing something wrong.
<cfcomponent output="false">
<cffunction name="service_login_authentication" access="remote" output="true" returntype="any" hint="Returns login">
<cfargument name="login" type="string" required="yes">
<cfargument name="password" type="string" required="yes">
<cfset var isLoginValid = False>
<cftry>
<cfif #arguments.login# eq "1111" and #arguments.password# eq "1111">
<cfset isLoginValid = True>
</cfif>
<cfif isLoginValid>
<cfsavecontent variable="soapRes"><?xml version="1.0" encoding="UTF-8"?>
<kps_response>
<message>OK</message>
<token>354dfdffsdf</token>
</kps_response>
</cfsavecontent>
<cfelse>
<cfthrow type="MyException" message="INVALID LOGIN" errorcode="1000" />
</cfif>
<cfcatch type="MyException">
<cfsavecontent variable="soapRes">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<soapenv:Fault>
<<cfoutput><faultcode>#cfcatch.errorCode#</faultcode>
<faultstring>#cfcatch.message#</faultstring></cfoutput>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
</cfsavecontent>
</cfcatch>
</cftry>
<cfreturn soapRes >
</cffunction>
</cfcomponent>
If my component is okay then may be possible some setting in ColdFusion administrator. i have checked in SoapUI as well via getSoapResponse method. -
Call Multiple Files From Single ColdFusion Scheduled Task
Our host only allows us to have 5 scheduled tasks per account but we need to run cfml applications to import data for multiple sites (at least 15 processes). What I'd like to do is combine all the 'sample requests' for all sites into ONE scheduled task that will run them one after another thus cutting back on the number of scheduled tasks needed.
We're using ColdFusion to connect to a MySQL DB to gather all sample requests. First the app retrieves all the unflagged records from a remote db then begins looping through all the returned records. On the each loop, the app 'scrubs' the data by properly formatting phone numbers, fixing address abbreviations, etc. Next the app saves the scrubbed data to a local MS SQL table then starts the loop over on the next row. Lastly the app sends out an email saying it has completed successfully.
What I'm trying to do is Create a New Parent App that will run as a scheduled task to do the following:
- New Parent App Runs as Scheduled Task and calls/includes first of X sample request app files
- New Parent App runs first sample request app as described above (which can take up to a minute to process)
- Parent app waits until after first sample request app completes, then Parent App goes on to second sample request app, etc.
- After all sample requests are complete New App sends completion email with date and time
The problem I'm having is getting the scheduled task to wait for apppage1.cfm to finish before loading apppage2.cfm and so on. Can you give me a simple codeset that accomplishes this?
I've attached a sample of the include page the needs to complete before moving on!Our approach is a bit more comprehensive.
First, we (meaning my co-workers) wrote a custom tag that does something like this:
<cftry>
<cfinclude the template>
<cfcatch>
log any errors
Then our actual scheduled job go like this:
set a really long timeout (and none of the actual jobs can have their own timeout)
set some variables
use the custom tag for each job we want to run
send mail if any errors occurred. -
Creating a cfhttp multi part form post for google docs upload
Hey all,
If you saw my last thread, you know I am working with google docs and uploading documents to it. Well I got basic document uploading working, but now I am trying to include meta data. Google requires you to include the metadata with the actual file data and seperate them by using a multi part form upload. I don't know exactly the process for doing so, but they have a handy code snippet of the desired results at
http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#UploadingDoc s
So I am basically trying to mimic that payload, however I am continually getting an error stating that there are no parts in a multi part form upload.
<errors xmlns='http://schemas.google.com/g/2005'><error><domain>GData</domain><code>InvalidEntryException</code><internalReason>No parts detected in multipart message</internalReason></error></errors>
to be exact. I am not really sure what I am doing wrong here. I figure it is one of two things, either I am not including the actual data in the payload properly (I am currently using a body type param for the payload, but I have also tried a formfield named content to deliver it. Neither worked). So maybe I need to do something else tricky there? The other thing which I am not reallly sure about is the content-length attribute. I don't know exactly how to calculate that, and I read in another forum that a content length attribute was messing that guy up. Right now I am just taking the lenght of the payload string and multiplying by 8 (to get the number of bytes for the entire payload) but hell if I know if that is right. It could be I just don't know how to set up the parts for the message, it seems pretty straight forward though. Just define a boundary in the content-type, then put two dashes before it wherever you define a new part, and two dashes trailing the last part.
Anyway, here is my code, any help is much appreciate. I'm a bit beyond my expertise here (not really used to trying to have to roll my own http requests, nevermind multipart post form data) so I'm kinda flailing around. Thanks again.
<cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
<cfargument name="filePath" type="string" required="false" hint="file to upload.">
<cfargument name="docType" type="string" required="yes" hint="The document type to identify this document see google list api supported documents">
<cfargument name="parentCollectionId" type="string" required="no" hint="the name of the collection/collection to create (include collection%3A)">
<cfargument name="metaData" type="struct" required="no" hint="structure containing meta data. Keyname is attribute name, value is the value">
<cfset var result = structnew()>
<cfset result.success = true>
<cftry>
<cfif structkeyexists(arguments,"parentCollectionId")>
<cfset arguments.parentCollectionId = urlencodedformat(parentCollectionId)>
<cfset result.theUrl = "https://docs.google.com/feeds/default/private/full/#arguments.parentCollectionId#/contents">
<cfelse>
<cfset result.theUrl = "https://docs.google.com/feeds/default/private/full/">
</cfif>
<cfoutput>
<cffile action="read" file="#arguments.filePath#" variable="theFile">
<cfsavecontent variable="atomXML">
Content-Type: application/atom+xml
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
<category scheme="http://schemas.google.com/g/2005##kind"
term="http://schemas.google.com/docs/2007###arguments.docType#"/>
<cfloop collection="#arguments.metaData#" item="key">
<#key#>#arguments.metadata[key]#</#key#>
</cfloop>
</entry>
--END_OF_PART
Content-Type: text/plain
#theFile#
--END_OF_PART--
</cfsavecontent>
</cfoutput>
<cfset result.postData = atomXML>
<cfhttp url="#result.theUrl#" method="post" result="httpRequest" charset="utf-8" multipart="yes">
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth()#">
<cfhttpparam type="header" name="GData-Version" value="3">
<cfhttpparam type="header" name="Content-Length" value="#len(trim(atomXML))*8#">
<cfhttpparam type="header" name="Content-Type" value="multipart/related; boundary=END_OF_PART">
<cfhttpparam type="header" name="Slug" value="test file --END_OF_PART">
<cfhttpparam type="body" name="content" value="#trim(atomXML)#">
</cfhttp>
<cftry>
<cfset packet = xmlParse(httpRequest.fileContent)>
<cfif httpRequest.statusCode neq "201 created">
<cfthrow message="HTTP Error" detail="#httpRequest.fileContent#" type="HTTP CODE #httpRequest.statusCode#">
</cfif>
<cfset result.data.resourceId = packet.entry['gd:resourceId'].xmlText>
<cfset result.data.feedLink = packet.entry['gd:feedLink'].xmlText>
<cfset result.data.title = packet.entry.title.xmlText>
<cfset result.data.link = packet.entry.title.xmlText>
<cfcatch>
<cfset result.data = httpRequest>
</cfcatch>
</cftry>
<cfcatch type="any">
<cfset result.error = cfcatch>
<cfset result.success = false>
</cfcatch>
</cftry>
<cfreturn result>
</cffunction>
Also, this is what my atomXML data ended up looking like when it got sent to google. This isn't the WHOLE request (it doesn't include the headers, just the body).
Content-Type: application/atom+xml
<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/docs/2007#document"/>
<TITLE>Woot Test</TITLE> </entry>
--END_OF_PART
Content-Type: text/plain
I'm a test document lol!
--END_OF_PART--Woot, I got it. I had to send the gData version number, and change the URL.
Here is the working function.
<cffunction name="upload" access="public" returnType="any" hint="I upload the document." output="false">
<cfargument name="myFile" type="string" required="false" hint="file to upload.">
<cfset var result = "">
<cfset theUrl = "https://docs.google.com/feeds/default/private/full">
<cffile action="read" file="C:\website\xerointeractive\testing\test.txt" variable="theFile">
<cfset fileSize = createObject("java","java.io.File").init("C:\website\xerointeractive\testing\test.txt").length()>
<cfhttp url="#theURL#" method="post" result="result" charset="utf-8" >
<cfhttpparam type="header" name="Authorization" value="GoogleLogin auth=#getAuth()#">
<cfhttpparam type="header" name="Content-Type" value="text/plain">
<cfhttpparam type="header" name="Slug" value="test file">
<cfhttpparam type="header" name="GData-Version" value="3">
<cfhttpparam type="header" name="Content-Length" value="#fileSize#">
<cfhttpparam type="body" value="#theFile#">
</cfhttp>
<cfreturn result>
</cffunction> -
I've got a function in a CFC that inserts a parent value into
an Oracle table (see below). I want to extend the function to
return the new parent ID so that I can use it to insert the child
values. I'm using <cfscript> to execute the function which
works fine with the data insert, but I can't quite work out how to
output the new parent ID value in <cfscript>. Any help
appreciated.
Thanks in advance
Roy.
<cffunction name="insertApp" hint="Insert Applications"
returntype="query">
<cftry>
<!--- Insert Values --->
<cfquery name="qryAppInsert" username='#this.uid#'
password='#this.pwd#' datasource='#this.source#'>
INSERT INTO
impsapp.tblAPPLICATIONS
VALUES
(#this.ID#, '#this.dType#',
TO_DATE('#this.cDate#','dd-mon-yyyy'))
</cfquery>
<!--- Select current Value form DUAL --->
<cfquery name="qryNewSeq" username='#this.uid#'
password='#this.pwd#' datasource='#this.source#'>
SELECT impsapp.Test_SEQ.currval x FROM dual
</cfquery>
<cfcatch type="any">
<cfreturn "Error in Function insertApp">
</cfcatch>
</cftry>
<!--- Return Query --->
<cfreturn qryNewSeq>
</cffunction>
<cfscript>
// create componet object
comTest = createObject("component", "cfc.Test");
// Set the properties from Form
comTest.uid = '#myUser#';
comTest.pwd = '#myPasswd#';
comTest.source = '#myDS#';
comTest.holder= #Form.eID#;
comTest.appType = '#Form.pType#';
comTest.recDate = '#DateFormat("#Form.dateReq#",
"dd/mmm/yyyy")#';
//Call insert finction
apply_Card.insertApplications();
//I need to be able to output and use the value x from the
qryNewSeq above
</cfscript>YourQuery = comTest.insertApp();
Your function might be too complicated. If this.id is the
same as test_seq.currval, why bother with the second query? -
AD and adding group members via CFLDAP
I posted this over in Advanced techniques with only one
brave, yet
unfortunately uninformed taker...
Anyone here have a clue as to why I'd get the error described
in the
text below???
[Only Response...]
Thank you for your response... I probably should explain
better what
this code does...
It queries a data source (DB2 database) for a list of about
2000 names
(specifically their Employee number).
Then it queries the MS Active directory for a list of anyone
who has an
attribute of employeeNumber that
is not an empty string.
Next, it uses a QofQ to join the two record sets together,
tossing out
any records that do not match from
both of the data sources.
Then I loop over that list of employees adding them into a
group.
This operation dos nothing to modify a users password.
Thanks,
D.
Ian Skinner wrote:
> This came off of another CF related list. Not sure if it
applies to
> your situation or not.
>
> * You cannot change passwords unless you have a SSL cert
setup for the
> CF server and the AD domain controller.
>
> I have not first hand experience with this, so all I can
offer is to
> pass along the above comment.
>
> dnagel wrote:
>> So, this is the advanced techniques group... and no
one feels the
>> least bit challenged?
>> Theres got to be someone who enjoys delving into
LDAP out there...
>>
>> D.
I'm having a bit of trouble getting the CFLDAP Modify query
to execute
after
I tied it into the CFLOOPed query... When I ran it with my
own users DN it
worked great... it does not work with any other DN. My
account has Domain
Adminis on this sandboxed server and is capable of making the
change by hand
using the AD tools inside of MMC... Any suggestions? Thanks,
D.
<cfset servername = "AD.TESTSITE.com">
<cfset username = "[email protected]">
<cfset password = "PASSWORD">
<cfset domain = "TESTSITE">
<cfset OU = "ou=Granite">
<cfoutput>
<CFSet GroupName="TestDistribution">
<CFSet GroupDN =
"cn=#GroupName#,cn=Users,dc=#domain#,dc=com">
<CFQuery name="Users" datasource="GCI_Workforce">
Select cast (WBAN8 as varchar(10)) as WBAN8, wbemal from
WTWDSECPJ1 where WBEXEMPT ='Y'
</CFQuery>
<cfldap
action="query"
server = "#servername#"
username = "#username#"
password = "#password#"
start = "#OU#,dc=#domain#,dc=com"
attributes = "dn,employeeNumber"
filter = "employeeNumber=*"
name = "adDNLookup"
scope = "subtree"
>
<CFQuery Name="JoinUsers" DBType="Query">
Select
adDNLookup.DN, adDNLookup.employeeNumber
from
adDNLookup,
Users
Where
adDNLookup.employeeNumber = Users.wban8
</CFQuery>
<CFLoop Query="JoinUsers">
<CFTry>
<!---<CFSet UserDN = "member=cn=Dennis
Nagel,CN=Users,DC=TESTSITE,DC=com">--->
<CFSet UserDN = "member=#DN#">
<CFSet UserName="#employeeNumber#">
#UserName# #UserDN#<br>
<cfldap
action="modify"
server = "#servername#"
username = "#username#"
password = "#password#"
modifytype="add"
attributes = "#UserDN#"
dn="#GroupDN#"
separator=";"
>
<cfoutput>#UserName# has been added to the group
(#GroupName#).</cfoutput>
<cfcatch type="any">
<cfif FindNoCase( "ENTRY_EXISTS", cfcatch.message )>
<cfoutput>
#UserName# is already assigned to the group
(#GroupName#).
</cfoutput>
<cfelse>
<cfoutput>
Unknown error : #cfcatch.detail#")
</cfoutput>
<cfabort>
</cfif>
</cfcatch>
</CFTry>
</CFLoop>
</cfoutput>
heres the trace info...
110028 member=CN=Mary Chalfa, OU=PSP_Indio, OU=PSP,
OU=GC_Branches,
ou=Granite, dc=TESTSITE, dc=com
Unknown error : One or more of the required attributes may be
missing/incorrect or you do not have permissions to execute
this
operation on the server")
Debugging Information ColdFusion Server Enterprise
6,1,0,63958
Template /JDE-AD-Sync/JDE-AD-Groups.cfm
Time Stamp 22-Jun-06 12:02 PM
Locale English (US)
User Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;
SV1; .NET
CLR 1.1.4322; .NET CLR 1.0.3705)
Remote IP 127.0.0.1
Host Name 127.0.0.1
Execution Time
Total Time Avg Time Count Template
687 ms 687 ms 1
C:\Inetpub\wwwroot\JDE-AD-Sync\JDE-AD-Groups.cfm
0 ms 0 ms 1 C:\Inetpub\wwwroot\JDE-AD-Sync\Application.cfm
0 ms STARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
687 ms TOTAL EXECUTION TIME
red = over 250 ms average execution time
Exceptions
12:02:45.045 - Application Exception - in
C:\Inetpub\wwwroot\JDE-AD-Sync\JDE-AD-Groups.cfm : line 67
An error has occured while trying to execute modify :[LDAP:
error code 49 - 80090308: LdapErr: DSID-0C090334, comment:
AcceptSecurityContext error, data 525, vece].
SQL Queries
Users (Datasource=GCI_Workforce, Time=47ms, Records=2203) in
C:\Inetpub\wwwroot\JDE-AD-Sync\JDE-AD-Groups.cfm @
12:02:44.044
Select cast (WBAN8 as varchar(10)) as WBAN8, wbemal from
WTWDSECPJ1 where WBEXEMPT ='Y'
JoinUsers (Datasource=, Time=16ms, Records=996) in
C:\Inetpub\wwwroot\JDE-AD-Sync\JDE-AD-Groups.cfm @
12:02:45.045
Select
adDNLookup.DN, adDNLookup.employeeNumber
from
adDNLookup,
Users
Where
adDNLookup.employeeNumber = Users.wban8
Scope Variables
Application Variables:
applicationname=JDE-AD-Sync
ds=GCI_WFD
Cookie Variables:
JSESSIONID=36301107041151000811062
Server Variables:
COLDFUSION=Struct (8)
OS=Struct (5)
Session Variables:
cfid=831
cftoken=54562187
sessionid=JDE-AD-SYNC_831_54562187
urltoken=CFID=831&CFTOKEN=54562187
Debug Rendering Time: 63 msok, I found it... re-use of the vaiable username... : -)
Damn ambiguous error messages.
Thanks to Ian for taking a look.
D. -
Creating a COM object with CF9 32-bit on Windows Server 2008 R2 64-bit machine
I'm using a 32-bit version of CF9 and it's installed on a Windows Server 2008 R2 machine (64-bit). The problem I'm running into is that it won't allow me to create a COM object - it gives me the error, "no ntvinv in java.library.path null" when I try to run,
<cftry>
<cfobject type="COM" action="CONNECT" name="Engine" class="JRO.JetEngine">
<cfcatch type="Any">
<cfobject type="COM" action="CREATE" name="Engine" class="JRO.JetEngine">
</cfcatch>
</cftry>
Then when I run it a 2nd time, I get "An exception occurred when instantiating a COM object. The cause of this exception was that: java.lang.RuntimeException: Can not use native code: Initialisation failed."
Can you help me?Replying for your patchset installation pre-req error:
Use below command:
./runInstaller -ignoreSysPrereqs
Review MOS note 763143.1 for more info. -
Wierd ColdFusion erro : Error occurred while processing request.
Hi there ,
I am a graduate student and new to ColdFusion.I started working on this already developed project by someone couple of years ago , and the client wants some changes to be done.so i went ahead and did some small modifications to the appearance of the form(insertdata.cfm page) like adding some more options to a drop down menu , changing the label names and so on and am very sure this changes would not have effected the application in any way.And the place where the message says the error can be , i didnt even touch that part.Now after 4 days i start getting this weird error saying " Error Occurred While Processing Request
The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code.
Null Pointers are another name for undefined values."
And this happens randomly not everytime i access the website or different webpages.Here are the errors.
The error occurred in /export/web/virtual/web3_unt_edu/cps/webaccess/sites/Amarillo/index.cfm: line 8
5 : SELECT UserName,Password FROM user_data WHERE UserName=
6 : <cfqueryparam value="#FORM.UserName#" maxlength="8">
7 : AND Password=
8 : <cfqueryparam value="#FORM.Password#" maxlength="8">
9 : </cfquery>
10 : <cfif MM_rsUser.RecordCount NEQ 0>
I tried adding " cfsqltype="cf_sql_clob" " in cfqueryparam also on my friends advice , but it doesnt work out.
2nd ERROR
The error occurred in /export/web/virtual/web3_unt_edu/cps/webaccess/sites/Amarillo/InsertData.cfm: line 13
11 : <cflocation url="#MM_failureURL#" addtoken="no">
12 : </cfif>
13 : <cfquery name="rsDay" datasource="cps">
14 : SELECT days FROM days
15 : </cfquery>
3rd ERROR
The error occurred in /export/web/virtual/web3_unt_edu/cps/webaccess/sites/Amarillo/InsertData.cfm: line 27
25 : ORDER BY ethnicity ASC
26 : </cfquery>
27 : <cfquery name="rsHospitals" datasource="cps_amarillo">
28 : SELECT *
29 : FROM hospitals
Can anyone help me with this. I have to get the modifications done in 2 weeks.
Thank you
CrajHi Mak
I can get the stack trace for now , but here is my complete code , may be this ll give u complete idea .........
The index page where i am getting the first error
<cfif IsDefined("FORM.UserName")>
<cfset MM_redirectLoginSuccess="menu.cfm">
<cfset MM_redirectLoginFailed="../../fail.htm">
<cfquery name="MM_rsUser" datasource="cps_amarillo">
SELECT UserName,Password FROM user_data WHERE UserName=
<cfqueryparam value="#FORM.UserName#" maxlength="8">
AND Password=
<cfqueryparam value="#FORM.Password#" maxlength="8">
</cfquery>
<cfif MM_rsUser.RecordCount NEQ 0>
<cftry>
<cflock scope="Session" timeout="30" type="Exclusive">
<cfset Session.MM_Username=FORM.UserName>
<cfset Session.MM_UserAuthorization="">
</cflock>
<cfif IsDefined("URL.accessdenied") AND true>
<cfset MM_redirectLoginSuccess=URL.accessdenied>
</cfif>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
<cfcatch type="Lock">
<!--- code for handling timeout of cflock --->
</cfcatch>
</cftry>
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfset MM_LoginAction=CGI.SCRIPT_NAME>
<cfif CGI.QUERY_STRING NEQ "">
<cfset MM_LoginAction=MM_LoginAction & "?" & XMLFormat(CGI.QUERY_STRING)>
</cfif>
</cfif>
<cfinclude template="../../../Connections/cps_amarillo.cfm">
<cfif IsDefined("FORM." & "UserName")>
<cfscript>
MM_valUsername=Evaluate("FORM." & "UserName");
MM_fldUserAuthorization="";
MM_redirectLoginSuccess="menu.cfm";
MM_redirectLoginFailed="../../fail.htm";
MM_dataSource=MM_cps_amarillo_DSN;
MM_queryFieldList = "UserName,Password";
if (MM_fldUserAuthorization IS NOT "") MM_queryFieldList=MM_queryFieldList & "," & MM_fldUserAuthorization;
</cfscript>
<cfquery datasource=#MM_dataSource# name="MM_rsUser" username=#MM_cps_amarillo_USERNAME# password=#MM_cps_amarillo_PASSWORD#>
SELECT #MM_queryFieldList# FROM user_data WHERE UserName='#Replace(MM_valUsername,"\'","
","ALL")#' AND Password='#FORM.Password#'
</cfquery>
<cfif MM_rsUser.RecordCount GREATER THAN 0>
<cfscript>
// username and password match - this is a valid user
Session.MM_Username = MM_valUsername;
if (MM_fldUserAuthorization IS NOT "") {
Session.MM_UserAuthorization = MM_rsUser[MM_fldUserAuthorization][1];
} else {
Session.MM_UserAuthorization = "";
if (IsDefined("accessdenied") AND true) {
MM_redirectLoginSuccess = Evaluate("accessdenied");
</cfscript>
<cflocation url="#MM_redirectLoginSuccess#" addtoken="no">
</cfif>
<cflocation url="#MM_redirectLoginFailed#" addtoken="no">
<cfelse>
<cfscript>
MM_LoginAction = CGI.SCRIPT_NAME;
if (CGI.QUERY_STRING NEQ "") MM_LoginAction = MM_LoginAction & "?" & CGI.QUERY_STRING;
</cfscript>
</cfif>
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Amarillo Login Screen</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
//-->
</script>
</head>
<body>
<div id="Layer2" style="position:absolute; left:26px; top:112px; width:683px; height:56px; z-index:2">
<div align="right"><font size="+6"><strong><font color="#999999" size="5" face="Verdana, Arial, Helvetica, sans-serif">Seniors
/ Volunteers for Childhood Immunization<br />
</font></strong></font><font color="#999999" size="5"><strong><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Web
Access Database</font></strong></font></div>
</div>
<div id="instructions" style="position:absolute; left:160px; top:182px; width:259px; height:30px; z-index:3"><font color="#999999" size="5"><strong><font size="4" face="Verdana, Arial, Helvetica, sans-serif">Please
enter your user name and password...</font></strong></font></div>
<div id="LayerLogin" style="position:absolute; left:427px; top:182px; width:310px; height:94px; z-index:4">
<form ACTION="<cfoutput>#MM_loginAction#</cfoutput>" name="form1" id="form1" method="POST">
<p><img src="../../../images/image14.gif" alt="" name="UserNameImg" width="150" height="21" border="0" id="UserNameImg" />
<input name="UserName" type="text" id="UserName" size="15" maxlength="15" />
<br />
<img src="../../../images/image15.gif" alt="" name="PasswordImg" width="150" height="21" border="0" id="PasswordImg" />
<input name="Password" type="password" id="Password" size="17" maxlength="15" />
</p>
<p align="right">
<input name="Submit" type="submit" id="Submit" onclick="MM_validateForm('UserName','','R','Password','','R');return document.MM_returnValue" value="Log In!" />
</p>
</form>
</div>
</body>
</html>
I checked it again and again , but the code seems to work well on a local host ..... but not whn i upload it to server. Please let me know where i am goin wrong.
Thank you -
Error message from database stored procedures
I would like to have some error message show at client side from stored procedures.
I use MS SQL Server and use RAISEERROR, but ColdFusion does not bring the error message just ignore the error continue to run the other part of code.
I just want to know are there any way to bring stroed procedure error message to client, or I have to trap the error at Web Server or JavaScript level.
Your help and information is great appreciated,
Regards,
Iccsi,Just wrap your cfstoredproc in a cftry/cfcatch. See this for an example:
http://stackoverflow.com/questions/1879754/accessing-raiseerror-message-from-cfstoredproc
There's no way your javascript can trap this server-side error though, unless you were calling your CFM page that calls the stored proc via an AJAX request. -
Problem with return a ColdFusion query object from a Java class
Hi!
I need to return a ColdFusion query object from a Java class
using a JDBC result set ( java.sql.ResultSet);
I have tried to pass my JDBC result set in to the constructor
of the coldfusion.sql.QueryTable class with this code:
ColdFusion code
<cfset pra = createObject("java","QueryUtil").init()>
<cfset newQuery = CreateObject("java",
"coldfusion.sql.QueryTable")>
<cfset newQuery.init( pra.getColdFusionQuery () ) >
My java class execute a query to db and return QueryTable
Java code (QueryUtil.java)
import coldfusion.sql.QueryTable; // (CFusion.jar for class
QueryTable)
import com.allaire.cfx //(cfx.jar for class Query used from
QueryTable)
public class QueryUtil
public static coldfusion.sql.QueryTable
getColdFusionQuery(java.sql.ResultSet rs)
return new coldfusion.sql.QueryTable(rs);
but when i run cfm page and coldfusion server tries to
execute : "<cfset pra =
createObject("java","QueryUtil").init()>" this error appears:
Object Instantiation Exception.
An exception occurred when instantiating a java object. The
cause of this exception was that: coldfusion/sql/QueryTable.
If i try to execute QueryUtil.java with Eclipse all it works.
Also I have tried to return java.sql.ResultSet directly to
coldfusion.sql.QueryTable.init () with failure.
Do you know some other solution?ok
i print all my code
pratica.java execute a query to db and return a querytable
java class
import java.util.*;
import java.sql.*;
import coldfusion.sql.*;
public class Pratica {
private HashMap my;
private String URI,LOGIN,PWD,DRIVER;
private Connection conn=null;
//funzione init
//riceve due strutture converite in hashmap
// globals
// dbprop
public Pratica(HashMap globals,HashMap dbprop) {
my = new HashMap();
my.put("GLOBALS",globals);
my.put("DBPROP",dbprop);
URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
LOGIN = "usr_dev";
PWD = "developer";
DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
try{
// Carico il driver JDBC per la connessione con il database
MySQL
Class.forName(DRIVER);
/* Connessione alla base di dati */
conn=DriverManager.getConnection(URI,LOGIN,PWD);
if(conn!=null) System.out.println("Connection Successful!");
} catch (ClassNotFoundException e) {
// Could not find the database driver
System.out.print("\ndriver non trovato "+e.getMessage());
System.out.flush();
catch (SQLException e) {
// Could not connect to the database
System.out.print("\nConnessione fallita "+e.getMessage());
System.out.flush();
//funzione search
//riceve un hash map con i filtri di ricerca
public QueryTable search(/*HashMap arg*/) {
ResultSet rs=null;
Statement stmt=null;
QueryTable ret=null;
String query="SELECT * FROM TAN100pratiche";
try{
stmt = conn.createStatement();// Creo lo Statement per
l'esecuzione della query
rs=stmt.executeQuery(query);
// while (rs.next()) {
// System.out.println(rs.getString("descrizione"));
catch (Exception e) {
e.printStackTrace();
try {
ret = Pratica.RsToQueryTable(rs);
} catch (SQLException e) {
e.printStackTrace();
this.close();
return(ret);
// ret=this.RsToQuery(rs);
// this.close(); //chiude le connessioni,recordset e
statament
//retstruct CF vede HashMap come struct
//METODO DI TEST
public HashMap retstruct(){
return(my);
//conversione resultset to querytable
private static QueryTable RsToQueryTable(ResultSet rs)
throws SQLException{
return new QueryTable(rs);
//chiura resultset statament e connessione
private void close(){
try{
conn.close();
conn=null;
catch (Exception e) {
e.printStackTrace();
coldfusion code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN">
<html>
<head>
<title>Test JDBC CFML Using CFScript</title>
</head>
<body>
<cftry>
<cfset glb_map =
createObject("java","java.util.HashMap")>
<cfset dbprop_map =
createObject("java","java.util.HashMap")>
<cfset glb_map.init(glb)> <!---are passed from
another page--->
<cfset dbprop_map.init(glb["DBPROP"])>
<cfset pra =
createObject("java","Pratica").init(glb_map,dbprop_map)>
<cfset ourQuery
=createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
<cfcatch>
<h2>Error - info below</h2>
<cfdump var="#cfcatch#"><cfabort>
</cfcatch>
</cftry>
<h2>Success - statement dumped below</h2>
<cfdump var="#ourQuery#">
</body>
</html>
error at line <cfset pra =
createObject("java","Pratica").init(glb_map,dbprop_map)>
An exception occurred when instantiating a java object. The
cause of this exception was that: coldfusion/sql/QueryTable.
----------------------------------------------------------------------- -
How to get soap request in webservices (WSDL in java)
hi ,,
i did one helloworld app using soap protocol. In that , one soap client invokes the webservices(old java class with WSDL ).Now i want to get the soap document in the web service for to process the soap envelope and parsing and generating the o/p and append to the response then create the soap document for response. plz let me know how to do?
Thanks in advance.Let me see whether I understand. Are you attempting to achieve something like this:
test.cfc
<cfcomponent output="no">
<cffunction name="testFunction" returntype="any" access="remote">
<cfargument name="soapInput">
<cfset var inputXML = arguments.soapInput>
<cfset var soapBodyText="">
<cfset var noBodyTextError="">
<cftry>
<cfset soapBodyText = xmlSearch(inputXML,"//soapenv:Body/text()")[1].xmlValue>
<cfsavecontent variable="noBodyTextError"><?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <soapenv:Fault> <faultcode>soapenv:Server.userException</faultcode> <faultstring>java.lang.Exception: Body not found.</faultstring></cfsavecontent>
<cfif trim(soapBodyText) is "">
<cfthrow>
</cfif>
<cfreturn inputXML>
<cfcatch type="any">
<cfreturn noBodyTextError>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
tester.cfm
<cfxml variable="mydata">
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wor="https://www.worldmilesafrica.com">
<soapenv:Header/>
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>
</cfxml>
<cfinvoke webservice = "http://127.0.0.1:8500/workspace/wsTest/test.cfc?wsdl"
method = "testFunction"
returnVariable = "result">
<cfinvokeargument name="soapInput" value="#trim(mydata)#" >
</cfinvoke>
<cfdump var="#result#">
Maybe you are looking for
-
Invisible bootcamp partition after failed removal
Hi everyone In the process of removing a Windows partition, I accidentally quit Bootcamp (trying to quit another application). Now, the partition neither shows up in Disk Utility nor anywhere else - of course disk space still taken. Disk repair didn'
-
Plz
-
Account Life cycle: Screen Control
Hi experts. I want to: Display additional assignment blocks that should only be available if the account is in a certain life cycle stage. Hide assignment blocks that should not be available in certain life cycle stages. I have implemented the Busine
-
Dear Team, My purchase order / PR release strategy should be reset, due to following reasons. 1. Any changes in Item Text / Header Text 2. Any changes in PVC / LD clauses & Base dates 3. Any changes in Retention / Advance % 4. Changes in Delivery Dat
-
What is the best strategy to use both Z10 and Q10?
Assume I have both a Z10 and Q10 and I'd like to use it on alternate days, what's the best strategy to do so? BBM should be fine with the same BlackBerry ID and it can just keep switching between the 2 devices. If I am using local contacts and calend