在开发机上建库,建表。

This commit is contained in:
Kane Wang 2021-06-21 11:36:18 +08:00
parent ec9adab717
commit fb6e431c8f
8 changed files with 175 additions and 45 deletions

View File

@ -9,6 +9,7 @@
<webroots> <webroots>
<root url="file://$MODULE_DIR$/web" relative="/" /> <root url="file://$MODULE_DIR$/web" relative="/" />
</webroots> </webroots>
<sourceRoots />
</configuration> </configuration>
</facet> </facet>
</component> </component>

View File

@ -17,74 +17,71 @@ public class StaffInfo
private String departmentCode; private String departmentCode;
private String departmentName; private String departmentName;
public StaffInfo( String staffCode ) throws StaffCodeNotExistException, OracleConnectionException, ClassNotFoundException, SQLException { private static String oracleURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
if ( staffCode.length() < 3 )
{ public StaffInfo(String staffCode) throws
throw new StaffCodeNotExistException( staffCode + "不存在。"); StaffCodeNotExistException,
OracleConnectionException,
ClassNotFoundException,
SQLException
{
if (staffCode.length() < 3) {
throw new StaffCodeNotExistException(staffCode + "不存在。");
} }
//url要改成可配置的
//String oracleURL = "jdbc:oracle:thin:@10.187.11.164:1521:xmcx1"; //String oracleURL = "jdbc:oracle:thin:@10.187.11.164:1521:xmcx1";
String oracleURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1"; //String oracleURL = "jdbc:oracle:thin:@10.39.0.86:1521:xmcx1";
String oracleUserName = "idst0"; String oracleUserName = "idst0";
String oraclePassword = "cpic123456"; String oraclePassword = "cpic123456";
this.staffCode = staffCode; this.staffCode = staffCode;
Class.forName( "oracle.jdbc.driver.OracleDriver" ); Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = null; Connection conn = null;
PreparedStatement stmt = null; PreparedStatement stmt = null;
ResultSet result = null; ResultSet result = null;
String sql = String sql =
"SELECT ry.staff_name,\n" + "SELECT ry.staff_name,\n" +
" ksh.section_office_code,\n" + " ksh.section_office_code,\n" +
" ksh.section_office_name,\n" + " ksh.section_office_name,\n" +
" bm.department_code,\n" + " bm.department_code,\n" +
" bm.department_name\n" + " bm.department_name\n" +
" FROM idst0.rydm_t ry,\n" + " FROM idst0.rydm_t ry,\n" +
" idst0.ks_t ksh,\n" + " idst0.ks_t ksh,\n" +
" idst0.bm_t bm\n" + " idst0.bm_t bm\n" +
" WHERE ry.staff_code = ?\n" + " WHERE ry.staff_code = ?\n" +
" AND ry.department_code = bm.department_code\n" + " AND ry.department_code = bm.department_code\n" +
" AND ry.section_office_code = ksh.section_office_code"; " AND ry.section_office_code = ksh.section_office_code";
try try {
{ conn = DriverManager.getConnection(oracleURL, oracleUserName, oraclePassword);
conn = DriverManager.getConnection( oracleURL, oracleUserName, oraclePassword );
stmt = conn.prepareStatement(sql); stmt = conn.prepareStatement(sql);
stmt.setString( 1, staffCode ); stmt.setString(1, staffCode);
result = stmt.executeQuery(); result = stmt.executeQuery();
if ( result.next() ) if (result.next()) {
{ staffName = result.getString("staff_name");
staffName = result.getString( "staff_name" ); sectionOfficeCode = result.getString("section_office_code");
sectionOfficeCode = result.getString( "section_office_code" ); sectionOfficeName = result.getString("section_office_name");
sectionOfficeName = result.getString( "section_office_name" ); departmentCode = result.getString("department_code");
departmentCode = result.getString( "department_code" ); departmentName = result.getString("department_name");
departmentName = result.getString( "department_name" );
} }
if ( staffName.isEmpty() == true ) if (staffName.isEmpty() == true) {
{
//没查到数据 //没查到数据
throw new StaffCodeNotExistException("工号" + staffCode + "不存在。"); throw new StaffCodeNotExistException("工号" + staffCode + "不存在。");
} }
} } catch (SQLException error) {
catch ( SQLException error ) throw new OracleConnectionException(error.getMessage());
{ } finally {
throw new OracleConnectionException( error.getMessage() ); try {
} if (conn != null) {
finally
{
try
{
if ( conn != null ) {
conn.close(); conn.close();
} }
} } catch (SQLException error) {
catch ( SQLException error )
{
//不处理了 //不处理了
} }
} }

View File

@ -0,0 +1,5 @@
create tablespace telsale datafile '/ora_data/DEV01/datafile/tel_sale/telsale_001.dbf' size 100m autoextend on maxsize 10g;
create user telsale identified by Cpic#1234 default tablespace telsale;

View File

@ -0,0 +1,49 @@
CREATE OR REPLACE PACKAGE telsale_policy_check_pkg IS
-- Author : Íõì¿
-- Created : 2021/6/21 10:18:01
-- Purpose : µçÏú±£µ¥Êý¾ÝÑéÖ¤
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN;
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN;
END telsale_policy_check_pkg;
/
CREATE OR REPLACE PACKAGE BODY telsale_policy_check_pkg IS
FUNCTION staff_check(a_stuff_code VARCHAR2) RETURN BOOLEAN IS
l_count INTEGER;
BEGIN
SELECT COUNT(*)
INTO l_count
FROM idst0.rydm_t@xmcx1.cpicxm ry
WHERE ry.staff_code = a_stuff_code;
IF l_count = 0
THEN
RETURN FALSE;
END IF;
RETURN TRUE;
END;
FUNCTION policy_check(a_policy_no VARCHAR2) RETURN BOOLEAN IS
l_count INTEGER;
BEGIN
SELECT COUNT(*)
INTO l_count
FROM idst0.auto_agreement_t@xmcx1.cpicxm a
WHERE a.policy_no = a_policy_no;
IF l_count = 0
THEN
RETURN FALSE;
END IF;
RETURN TRUE;
END;
BEGIN
NULL;
END telsale_policy_check_pkg;
/

View File

@ -0,0 +1,9 @@
create table
(
IP地址 varchar2(15),
varchar2(6),
varchar2(100),
P13账号 varchar2(100),
date,
varchar2(200)
);

View File

@ -0,0 +1,18 @@
create table
(
varchar2(20),
varchar2(20),
varchar2(100),
varchar2(20),
varchar2(100),
varchar2(20),
varchar2(100),
varchar2(20),
varchar2(100),
varchar2(20),
varchar2(100),
varchar2(20),
varchar2(100),
date
);

View File

@ -0,0 +1,12 @@
PL/SQL Developer Project Desktop
[Desktop]
SavePath=D:\develop\projects_win\2018\telsale_management_2017\代码\oracle\项目\
[Files]
[MRU]
1,D:\develop\projects_win\2018\telsale_management_2017\代码\oracle\项目\建表\电销保单信息表.sql
[Layout]
Group=

View File

@ -0,0 +1,39 @@
PL/SQL Developer Project
[Options]
AutoConnect=0
Username=telsale
Password=2093407949054803468536713937389938934015
Database=DEV01
ConnectAs=Normal
Edition=1.0
Workspace=电销转介绍
HaltAfterError=0
BrowseHistory=-1
FileBrowser=-1
BeautfierRulesFile=
VersionControl=0
VersionControlPath=
ShowItems=-1
[History]
Programs=D:\develop\projects_win\2019\car_dealer_util\代码\数据库\oracle\pkg
SQL Scripts=D:\develop\projects_win\2018\xmty_util_2018\代码\oracle\xmty\sql\查询测试
Report Files=
Test Scripts=
Command Scripts=
Diagram Files=
[BrowserFolders]
[Groups]
[Files]
1,0,,,建表\电销保单信息表.sql
[Notes]
{\rtf1\ansi\deff0\nouicompat{\fonttbl{\f0\fnil Arial;}}
{\*\generator Riched20 10.0.19041}\viewkind4\uc1
\pard\f0\fs20\lang2052\par
}