动态网站制作指南 [  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > 数据库 > Oracle教程
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
数据库:数据库教程,数据库技巧,Oracle教程,MySQL教程,Sybase教程,Access教程,DB2教程,数据库安全,数据库文摘
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Oracle教程 ]的信息

本月文章推荐
.用Oracle解析函数快速检查序列间.
.有关系统和X正常运行的两个问题.
.使用dbms_stats时如何才能不生成.
.oracle同时向多表插入数据.
.如何创建隐藏IP地址的最后一项的.
.Oracle rac安装过程详解(一).
.Oracle 9i新特性研究五(监视未使.
.在 Oracle 数据库上构建 .NET 应.
.菜鸟学oracle.
.Oracle:PL/SQL 中如何使用Array.
.解析MobiLink实现基于时间戳的分.
.详细解述oracle数据库九个基本操.
.尝试一些UNIX的提示和技巧.
.Oracle10g新增的用以简化用户管理.
.教你检测Oracle的可用性和表空间.
.Oracle数据库中Web分页方法详细介.
.如何使sendmail监听在其他端口?.
.vi 文书处理软体.
.IAS 9.0.2.0.1 for SUN OS 8 的启.
.关于exchange partition.

Windows服务:方便地启动Oracle服务

发表日期:2008-2-9 |


    Oracle 9i有多个系统服务必须都启动之后才能正常工作,但逐个启动比较费事,多数学习Oracle但机器又不是太好的朋友也不能容忍每次都自动启动Oracle服务(那样512MB的内存在启动时就所剩无几了),所以通常都是要用了再启动, 这里给出了批量启动windows系统服务的一个例子,介绍了操控windows系统服务的技巧:

首先新建一个Windows Application工程,取名为Oracle Starter
粘贴如下代码文件:
Form1.Designer.vb
Partial Public Class Form1
    Inherits System.Windows.Forms.Form     <System.Diagnostics.DebuggerNonUserCode()> _
    Public Sub New()
        MyBase.New()         ''''This call is required by the Windows Form Designer.
        InitializeComponent()     End Sub     ''''Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing AndAlso components IsNot Nothing Then
            components.Dispose()
        End If
        MyBase.Dispose(disposing)
    End Sub     ''''Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer     ''''NOTE: The following procedure is required by the Windows Form Designer
    ''''It can be modified using the Windows Form Designer. 
    ''''Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label
        Me.ListBox1 = New System.Windows.Forms.ListBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.SuspendLayout()
        ''''
        ''''Label1
        ''''
        Me.Label1.AutoSize = True
        Me.Label1.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.Label1.Location = New System.Drawing.Point(13, 13)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(122, 22)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Oracle Starter"
        ''''
        ''''ListBox1
        ''''
        Me.ListBox1.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.ListBox1.FormattingEnabled = True
        Me.ListBox1.ItemHeight = 19
        Me.ListBox1.Location = New System.Drawing.Point(13, 75)
        Me.ListBox1.Name = "ListBox1"
        Me.ListBox1.Size = New System.Drawing.Size(436, 175)
        Me.ListBox1.TabIndex = 1
        ''''
        ''''Button1
        ''''
        Me.Button1.Location = New System.Drawing.Point(322, 257)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(127, 34)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "Stop all services"
        ''''
        ''''Button2
        ''''
        Me.Button2.Location = New System.Drawing.Point(188, 258)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(127, 34)
        Me.Button2.TabIndex = 3
        Me.Button2.Text = "Start all servies"
        ''''
        ''''Form1
        ''''
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(461, 304)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.ListBox1)
        Me.Controls.Add(Me.Label1)
        Me.Name = "Form1"
        Me.Text = "Oracle Starter"
        Me.ResumeLayout(False)
        Me.PerformLayout()
    End Sub
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button End Class
Form1.vb

Imports System.ServiceProcess
Imports System.Threading Public Class Form1     ''''Private procName As String
    Private procArray(5) As String     Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated     End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        procArray(0) = "OracleMTSRecoveryService"
        procArray(1) = "OracleOraHome92Agent"
        procArray(2) = "OracleOraHome92TNSListener"
        procArray(3) = "OracleServiceSFSVDB"
        procArray(4) = "OracleOraHome92HTTPServer"
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim backThread As Thread
        Dim i As Int16
        For i = 0 To 4
            backThread = New Thread(AddressOf procClass.StopProc)
            backThread.IsBackground = True
            procClass.procName = procArray(i)
            Label1.Text = "Stopping service: " + procClass.procName + " ..."
            Me.Refresh()
            backThread.Start()
            backThread.Join()
            ListBox1.Items.Add("Service: " + procClass.procName + " Stopped")
            Me.Refresh()
            backThread = Nothing
        Next
        Label1.Text = "All services stopped"
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim backThread As Thread
        Dim i As Int16
        For i = 0 To 4
            backThread = New Thread(AddressOf procClass.StartProc)
            procClass.procName = procArray(i)
            Label1.Text = "Starting service: " + procClass.procName + " ..."
            Me.Refresh()
            backThread.Start()
            backThread.Join()
            ListBox1.Items.Add("Service: " + procClass.procName + " Started")
            Me.Refresh()
            backThread = Nothing
        Next
        Label1.Text = "All services started"
    End Sub     Public Class procClass
        Public Shared procName As String         Public Shared Sub StopProc()
            Dim servController1 As ServiceController = New ServiceController(procName)
            If servController1.Status = ServiceControllerStatus.Stopped Then
            ElseIf servController1.Status = ServiceControllerStatus.Paused Then
                servController1.Stop()
                servController1.WaitForStatus(ServiceControllerStatus.Stopped)
            ElseIf servController1.Status = ServiceControllerStatus.Running Then
                servController1.Stop()
                servController1.WaitForStatus(ServiceControllerStatus.Stopped)
            End If
        End Sub         Public Shared Sub StartProc()
            Dim servController1 As ServiceController = New ServiceController(procName)
            If servController1.Status = ServiceControllerStatus.Running Then
            ElseIf servController1.Status = ServiceControllerStatus.Paused Then
                servController1.Continue()
                servController1.WaitForStatus(ServiceControllerStatus.Running)
            ElseIf servController1.Status = ServiceControllerStatus.Stopped Then
                servController1.Start()
                servController1.WaitForStatus(ServiceControllerStatus.Running)
            End If
        End Sub
    End Class
End Class

总结:
这个实例只是运用了系统服务控制的基本功能,高级功能还不甚了解,对于多线程的运用还不是很明确,望大家指正

改进:
程序在运行时假如焦点离开,用户界面便会锁死,虽然尝试了多线程,仍然不理想,应该还Join()方法有关,多次修正未果,请高手指点,谢谢!


测试平台:
Windows Server 2003,Visual VB.NET 2005 Beta 1
上一篇:Oracle的客户端工具--sql*plus 人气:602
下一篇:解决.NET连到Oracle的oci.dll加载错误 人气:522
浏览全部Oracle教程的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-9-7 站长中国企业(公司)网站系统 v4.2
2008-9-7 PBDigg v2.0 Build 20080821
2008-9-7 玩玩小游戏FLASH系统 v2.1
2008-9-7 522QQ在线电视直播程序 v1.1
2008-9-7 Pcook cms 文章管理系统 (老Y CM
2008-9-7 仿代码小说小偷系统 v1.0
2008-9-7 百度一搜集成搜索管理系统
2008-9-7 小贤统计器 v1.0
2008-9-7 UCenter Home-中秋搏饼插件 v1.2
2008-9-7 iBlacklist通话黑名单汉化破解补
2008-9-7 EndlessWalls无尽壁纸 v1.0.4破解
2008-9-7 Dynolicious车载测量仪v1.1破解版
2008-9-7 iVoodoo巫毒娃娃1.0.1破解版
2008-9-7 iWallpape精品墙纸1.2破解版
2008-9-7 iChillout自然音效工具1.1破解版
2008-9-7 Todo计划提醒1.2破解版
2008-9-7 allRadio电台集合1.01破解版
2008-9-7 My Money个人理财1.0破解版
  发表评论
姓 名: 验证码:
内 容:
站长工具:网站收录查询 | Google PR查询 | ALEXA排名查询 | CSS在线编辑器 | 广告代码 | Html转换js | js/vbs加密 | md5加密 | 进制转换
实用工具:汉字翻译拼音 | 符号对照表 | 个税计算 | 经典小工具 | 汉字简繁转换 | 普通单位换算 | 公制单位换算 | 生辰老黄历 | 国内电话区号 国家代码与域名缩写 | 文字加密解密 | 健康查询 | 万年历 | 汉字横竖排版 | 手机号码查询 | 计算器 | ip搜索
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号