大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
'
创新互联建站是一家专业从事成都做网站、成都网站制作、网页设计的品牌网络公司。如今是成都地区具影响力的网站设计公司,作为专业的成都网站建设公司,创新互联建站依托强大的技术实力、以及多年的网站运营经验,为您提供专业的成都网站建设、营销型网站建设及网站设计开发服务!
'!!!重要:首先要添加“引用”一个dll,选择“System Management”;
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Management
Imports System.IO
Namespace WindowsApplication1
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取CPU编号
Dim [MyClass] As New ManagementClass("Win32_Processor")
Dim MyCollection As ManagementObjectCollection = [MyClass].GetInstances()
Dim MyInfo As String = "当前系统CPU编号是:"
Dim MyCPUID As String = ""
For Each MyObject As ManagementObject In MyCollection
MyCPUID = MyObject.Properties("ProcessorId").Value.ToString()
Exit For
Next MyObject
MyInfo = MyCPUID
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的当前电压
Dim MyInfo As String = "计算机CPU的当前电压是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
Try
MyInfo = ControlChars.Lf String.Format("CurrentVoltage : " MyObject("CurrentVoltage").ToString())
MyInfo = ControlChars.Lf "========================================================="
Catch
End Try
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button3_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的外部频率
Dim MyInfo As String = "计算机CPU的外部频率是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
Try
MyInfo = ControlChars.Lf String.Format("ExtClock : " MyObject("ExtClock").ToString())
MyInfo = ControlChars.Lf "========================================================="
Catch
End Try
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button4_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的二级缓存
Dim MyInfo As String = "计算机CPU的二级缓存尺寸是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("L2CacheSize: " MyObject("L2CacheSize").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button5_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的制造商名称
Dim MyInfo As String = "计算机CPU的制造商名称是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("Manufacturer : " MyObject("Manufacturer").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button6_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的产品名称
Dim MyInfo As String = "计算机CPU的产品名称是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("Name : " MyObject("Name").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button7_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的版本信息
Dim MyInfo As String = "计算机CPU的版本信息如下:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("Version: " MyObject("Version").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button8_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的当前使用百分比 注意要把SQLserver或者其他耗CPU的软件开着否则看不到效果就一直为0
Dim MyInfo As String = "计算机CPU的当前使用百分比是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("LoadPercentage : " MyObject("LoadPercentage").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button9_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的最大时钟频率
Dim MyInfo As String = "计算机CPU的最大时钟频率是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("MaxClockSpeed : " MyObject("MaxClockSpeed").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button10_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机CPU的当前时钟频率
Dim MyInfo As String = "计算机CPU的当前时钟频率是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("CurrentClockSpeed : " MyObject("CurrentClockSpeed").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button11_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机的CPU地址宽度
Dim MyInfo As String = "当前计算机的CPU地址宽度是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("AddressWidth: " MyObject("AddressWidth").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Private Sub button14_Click(ByVal sender As Object, ByVal e As EventArgs)
'获取计算机的CPU数据宽度
Dim MyInfo As String = "当前计算机的CPU数据宽度是:"
Dim MySearcher As New ManagementObjectSearcher("SELECT * FROM Win32_Processor")
For Each MyObject As ManagementObject In MySearcher.Get()
MyInfo = ControlChars.Lf String.Format("DataWidth : " MyObject("DataWidth").ToString())
MyInfo = ControlChars.Lf "========================================================="
Next MyObject
MessageBox.Show(MyInfo, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
你可以试以下几个方法同时用,效果会好些:
1、修改MSSQL的端口号;
2、修改复杂的SA密码,如aKLFJD13aaK_1@这一类,黑客就无法爆破了;
3、打开WIN的自带防火墙,仅开有用的80端口和远程桌面(记住远程桌面端口也改),别开21端口。
4、关闭PING功能。
用上面的方法可以大大提高你服务器的安全,其他的防火墙有一定的作用,但会占资源。
使用十六进制表示法来指定 LF 行终止符,即:ROWTERMINATOR = '0x0A'。
至于slq server为什么在CRLF的时候可以识别出\r\n,但是换到LF时只能识别16进制,我也没搞懂,猜想可能跟文件编码有关,但是没有实际验证。
第一步:从SQLSERVER中导出数据
在SQLSERVER数据库上使用Import and Export Data工具
1.在choose a Data source页
选取:
source= Microsoft OLE DB Porvider for Sql Server
server=local
database=icd_db_bill
{use Sql Server authentication}
user=sa
选择下一步
2.在choose destination 页中
选取destination为Text File
file name ="d:\backup\tbilllog1.txt"
选择下一步
3. 选择use a query to specify the data to transfer
选择下一步
注:由于SQLSERVER导出时会将table_id作为一个域导出,而oracle没有(oracle 为rowid),所以必须选择此项为use a query to specify the data to transfer而不是copy table(s) from source database
4.在Query Builder选项进入
选取tbilllog1,添加然后将table_id从列表中去掉
一直确认直到select Destination File Format页面
5.选择
file type =ansi (缺省)
row={cr}{lf} (缺省)
column=comma (缺省)
text= double quote{"} (缺省)
在comumn和text选项会影响到oracle的controlfile的设置
第二步:
oracle方面的设置
首先将tbilllog1.txt 拷贝到log1.ctl的目录
提示:如果NT平台可以先压缩再传送可以节省时间,到目的目录再解开
controlfile example: log1.ctl
LOAD DATA
INITFILE 'tbilllog1.txt'
insert into table tbilllog1
fields terminated by ',' optionally enclosed by '"'
(
callid,
callidnum,
callerno,
calleeno,
waitbegin date "yyyy--mm-dd hh24:mi:ss",
waitend date "yyyy-mm-dd hh24:mi:ss",
ackbegin date "yyyy-mm-dd hh24:mi:ss",
ackend date "yyyy-mm-dd hh24:mi:ss",
...
)
*fields terminated by ','指明域由,分割,对应到上面第5步的column=comma
*optionally enclose by '"'指明字符型数据有" "括起来,对应到text=double quote{"}如果选择text=none 不加此语句。
楼上的同志们,,,java连数据库方式有3种,
你们所说的那种是纯java驱动方式,无需配置数据源,但是要加特定的驱动包才可以
楼主用的连接方式JDBC-ODBC桥接方式,需要先配置数据源(虽然我不建议楼主使用这种方式,不便于移植,换个环境就要配置数据源先),jdk自带驱动.
连接代码没写错
建议:
1:如果你会VB的话,可以用VB简单测试一下数据源配置是否成功
2:将你的sql打印到控制台,再复制到查询分析器中去执行看看 看sql是否拼错
3:记得随手关闭连接和结果集
报错信息是sql异常 sql拼错的可能性比较大
下面的程序我测试通过 你把表名和dsn名改成你自己的,再加上密码就可以运行了
import java.sql.*;
public class Access {
public static void main(String args[]) {
Connection con;
Statement sql; // 声明Statement对象
ResultSet rs;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
System.out.println("" + e);
}
try {
con = DriverManager.getConnection("jdbc:odbc:MS Access Database", "", "");
sql = con.createStatement();
rs = sql.executeQuery("Select * FROM Mytable");
while (rs.next()) {
String colum1 = rs.getString(1); // 获得数据库第一列 System.out.println(colum1);
}
con.close();
} catch (SQLException el) {
System.out.println("" + el);
}
}
}