数据|数据库
1 建立系统ODBC 数据源photo(本次使用的是Oracle 9i,详细配置如有不懂这处再和我联系)
2 编译DataBaseConnection.java文件 将其编译文件放入到PHP支持的类文件目录中
package com.inberkong.util;
/*******************************************************
* Programe File :复件缓冲池DataBaseConnection.java
* Creat Date :3/28/2005(MM-DD-YYYY)
* Creat By :InberKong(GongYingBin)
* LastModifyDate :3/28/2005(MM-DD-YYYY)
* ModifyBy :InberKong(GongYingBin)
* Function :Get the Oracle DataBaseConnectionPool
//一个用于查找数据源的工具类。
*******************************************************/
import java.sql.*;
//连接数据库的工具类。
public class DataBaseConnection
{
/**
*一个静态方法,返回一个数据库的连接。
*/
public static Connection getConnection()
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:photo","photo","inberkong");//数据源连接信息
}
catch(Exception e)
{
e.printStackTrace();
}
return con;
}
}
3 编译读数据表的处理类同样将处理类放入PHP调用的Java类目录
这是一个读取用户角色表 返回用户与角色间关系的JS数组的处理类 GetUserRolseArray.java
注:读程序时不需要关心相关的表结构,可只关心整个调用的处理过程。
package com.inberkong.processBean;
import java.lang.*;
import java.sql.*;
import java.util.*;
import java.io.*;
import com.inberkong.util.DataBaseConnection;
public class GetUserRolseArray
{
private Connection conss;
private Statement stmtsss=null;
private Statement stmt2=null,stmt3=null;
private ResultSet rstsss=null;
private ResultSet rst2=null,rst3=null;
private String sqlss="";
private String sql2="",sql3="";
private String rString="";
private String ID,ID2;
private String NAME;
private int i=0;
public GetUserRolseArray()
{
try
{
this.conss=DataBaseConnection.getConnection();
}
catch(Exception e)
{
}
//DataBaseConnection.getConnection();
}
protected void finalize() throws Throwable
{
//
//super.finalize();
//System.out.println("inberkong");
closeCON();
}
public String getUserRolseArray() throws Exception
{
//exePtempfunction();
sqlss="SELECT ID,NAME FROM ADMIN WHERE 1=1 AND STATE!=0 AND USERTYPE!='0'
ORDER BY ID DESC";
//外部用户不参于后加角色管理
stmtsss=conss.createStatement();
rstsss=stmtsss.executeQuery(sqlss);
while (rstsss.next())
{
ID=rstsss.getString("ID");
ID2=ID;
NAME=rstsss.getString("NAME");
rString=rString+"\n"+"arr["+i+"]=new BDSort
('"+ID+"','00','"+NAME+"','');";
i++;
sql3="select ID,NAME from ROLE_MANAGE where ID in( select ROLSEID
from USER_ROLSE_LINK where USERID="+ID2+") order by ID asc ";
stmt3=conss.createStatement();
rst3=stmt3.executeQuery(sql3);
while(rst3.next())
{
ID=rst3.getString("ID");
NAME=rst3.getString("NAME");
rString=rString+"\n"+"arr["+i+"]=new BDSort
('"+ID+"','"+ID2+"','"+NAME+"','y');";
i++;
}
[1] [2] 下一页

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools