数据库连接配置文件书写|怎么写配置文件

|

1. mybatis通过windows方式连接sqlserver数据库配置文件怎么写

不验证用户名密码的登录方式可以在JDBC串里实现,但也要依托某种验证方式,例如下面这个使用k8s验证的连接串的写法:jdbc:sqlserver://;servername=server_name;integratedSecurity=true;authenticationScheme=javaKerberos把配置文件里原有的dataSource里面的url改了<property name="url" value="jdbc:sqlserver://;servername=server_name;integratedSecurity=true;authenticationScheme=JavaKerberos"/>

2. 怎么配置mysql数据库配置文件

一、mysql_install_db说明当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时,需要初始化mysql数据库。需要使用的命令:/usr/local/mysql/bin/mysql_install_db#/usr/local/mysql/bin/mysql_install_db –help 可以查看帮助信息如下Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS] –basedir=path The path to the MySQL installation directory. –cross-bootstrap For internal use. Used when building the MySQL system tables on a different host than the target. –datadir=path The path to the MySQL data directory. –force Causes mysql_install_db to run even if DNS does not work. In that case, grant table entries that normally use hostnames will use IP addresses. –ldata=path The path to the MySQL data directory. –rpm For internal use. This option is used by RPM files ring the MySQL installation process. –skip-name-resolve Use IP addresses rather than hostnames when creating grant table entries. This option can be useful if your DNS does not work. –srcdir=path For internal use. The directory under which mysql_install_db looks for support files such as the error message file and the file for popoulating the help tables. –user=user_name The login username to use for running mysqld. Files and directories created by mysqld will be owned by this user. You must be root to use this option. By default mysqld runs using your current login name and files and directories that it creates will be owned by you.All other options are passed to the mysqld program除了支持以上的参数,还支持mysqld的参数。二、举例: 本文以新加一个mysql实例为例。例如服务器上已经安装了3306端口的mysql服务,需要再启一个3308端口的mysql服务。 假设mysql安装在/usr/local/mysql路径下,找一个磁盘空间剩余比较大的盘,如/data1,把3308端口的mysql的数据保存在/data1下#mkdir /data1/mysql_3308#mkdir /data1/mysql_3308/data#chown -R mysql:mysql /data1/mysql_3308 复制一个mysql配置文件my.cnf到/data1/mysql_3308目录下#vi /data1/mysql_3308/my.cnf修改配置文件,将端口和相关目录的都改为新的设置,如下:[client]character-set-server = utf8port = 3308socket = /tmp/mysql_3308.sock[mysqld]user = mysqlport = 3308socket = /tmp/mysql_3308.sockbasedir = /usr/local/mysqldatadir = /data1/mysql_3308/datalog-error = /data1/mysql_3308/mysql_error.logpid-file = /data1/mysql_3308/mysql.pid……其他略 确保配置文件无误。运行下面命令进行数据库的初始化:#/usr/local/mysql/bin/mysql_install_db –defaults-file=/data1/mysql_3308/my.cnf –datadir=/data1/mysql_3308/data完成后新的3308数据库就初始化好了,如果有报错,则按照报错的提示查看报错日志,一般情况下都是my.cnf配置文件的问题,修正后即可。三、启动新mysql启动3308端口的mysql服务#/usr/local/mysql/bin/mysqld_safe –defaults-file=/data1/mysql_3309/my.cnf &检查是否启动#ps aux|grep mysql如果有3308字样说明已经启动成功可将启动命令加入/etc/rc.local随服务器启动新加的mysql没有设置root密码,可以通过下面命令设置root密码:#/usr/local/mysql/bin/mysqladmin -S /tmp/mysql_3308.sock -u root password 'new-password'

3. C#连接oracle数据库Add.config配置文件怎么写

C#连接Oracle数据库(查询数据) using System;using System.Collections.Generic;using System.ComponentModel;//这行和下一行都要先在引用中填加system.data.oracleclientusing System.Data.OracleClient;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms; namespace WindowsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { #region 从region到endregion是手工写的。别的都是系统自动生成的 //定义连接数据库的字符串 string constring = "data source=wzd;user=wzd;password=wzd;"; //进行连接 OracleConnection conn = new OracleConnection(constring); try { conn.Open();//打开指定的连接 OracleCommand com = conn.CreateCommand(); //写好想执行的Sql语句 com.CommandText = "select name from mytable where card_no='0000000002'"; OracleDataReader odr = com.ExecuteReader(); //读取数据,如果返回为false的话,就说明到记录集的尾部了 while (odr.Read()) { //将读取到的值显示到定义的控件中。 this.lbl.Text = odr.GetOracleString(0).ToString(); } odr.Close();//关闭reader.这是一定要写的 } catch { MessageBox.Show("erro");//如果发生异常,则提示出错 } finally { conn.Close();//关闭打开的连接 } #endregion } }}C#中与Oracle连接的代码 注意:一定要添加这个: 项目->添加引用->.NET->System.Data.OracleClient.dll using System;using System.Data;using System.Windows.Forms;using System.Data.OracleClient; namespace Test{ /// <summary> /// 简洁期间,直接将实现写在构造函数中 /// </summary> public class Test { public Test() { // // TODO: 在此处添加构造函数逻辑 // string ConnectionString = "Data Source=LiPu; User Id=SCOTT; Password=scott"; //连接字符串,Data Source 是指数据库名字.如我用的是本机的Oracle //的数据库,名字为LiPu. user id 是 //用户名,你可以用System 或是你自己添加的一个用户.Password是 //对应用户的密码. //创建一个新连接 OracleConnection conn = new OracleConnection(ConnectionString); try { conn.Open(); //打开连接 OracleCommand cmd = conn.CreateCommand(); cmd.CommandText = "select * from emp"; //SQL语句 OracleDataReader rs = cmd.ExecuteReader(); //读取数据,如果rs.Read()返回为false的话,就说明到记录集的尾部了 while(rs.Read()) { MessageBox.Show(rs.GetString(1)); } rs.Close(); } catch (Exception e) { MessageBox.Show(e.Message); } finally { conn.Close(); } } }} C#连接Oracle数据库(更改数据库中的记录并查询更改后的数据) using System;using System.Collections.Generic;//这行和下一行都要先在引用中填加system.data.oracleclientusing System.ComponentModel;using System.Data.OracleClient;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms; namespace WindowsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { #region 从region到endregion是手工写的。别的都是系统自动生成的 //定义连接数据库的字符串 string constring = "data source=wzd;user=wzd;password=wzd;"; //进行连接 OracleConnection conn = new OracleConnection(constring); try { conn.Open();//打开指定的连接 OracleCommand com = conn.CreateCommand(); com.CommandText = "select name from fin_ipr_inmaininfo where card_no="+ "'0000000002'";//写好想执行的Sql语句 OracleDataReader odr = com.ExecuteReader(); //读取数据,如果返回为false的话,就说明到记录集的尾部了 while (odr.Read()) { //将读取到的值显示到定义的控件中。 this.lbl.Text = odr.GetOracleString(0).ToString(); } odr.Close();//关闭reader.这是一定要写的 } catch { MessageBox.Show("erro");//如果发生异常,则提示出错 } finally { conn.Close();//关闭打开的连接 } #endregion } private void button2_Click(object sender, EventArgs e) { #region 从region到endregion是手工写的。别的都是系统自动生成的 //定义连接数据库的字符串 string constring = "data source=wzd;user=wzd;password=wzd;"; //进行连接 OracleConnection conn = new OracleConnection(constring); try { conn.Open();//打开指定的连接 OracleCommand com = conn.CreateCommand(); //写好想执行的Sql语句 com.CommandText = "update fin_ipr_inmaininfo set name='wzd' where card_no='0000000002'"; com.ExecuteNonQuery(); } catch { MessageBox.Show("erro");//如果发生异常,则提示出错 } finally { conn.Close();//关闭打开的连接 } #endregion } }}

4. 求教c#如何写连接数据库的配置文件,谢谢啊

<connectionStrings> <add name="+连接字符串名称+" connectionString="Data Source=数据库IP地址;Initial Catalog=您要使用的数据库的名字;User ID=登陆数据库的用户名;Password=登陆数据库的密码;" providerName="System.Data.SqlClient"/></connectionStrings/>

5. Winform中,配置文件怎么写来与数据库连接

添加一个应用程序配置文件,App.Config在<configuration>节点下添加 <connectionStrings>节点, <add name = "" connectionstring = "">剩下的和内Web.Config中差不多了容。

6. 怎么写配置文件

配置文件可以是任何形式,可以是xml或者txt都行,比如数据库的连接配置比如:?xmlversion="1.0"standalone="yes"?//这句一定要专有,下面的你随意写属这就是个配置文件,在winform里面直接用DataSet的ReadXml()方法就能读取到里面的值

7. eclipse如何连接服务器数据库,配置文件里怎么写

1.前边的事例是把数据库的驱动,连接,用户名和密码都写在了类中,耦合性太高,当我们数据库变更或者数据库类型更换后,需要去重新更改代码,很不方便。解决的方法:把数据库的驱动,连接,用户名和密码写在配置文件中,通过读取配置文件的方式进行代码编写,而以后如果数据库变更直接修改配置文件即可!2.在工程中右键新建file,命名为jdbc.properties3.创建完毕如图:4.在jdbc.properties文件中输入如下信息,分别是数据库的驱动,连接,用户名和密码5.新建JdbcTest2.java类6.输入如下代码:7.代码说明:这段代码是读取配置文件,把配置文件中的各个项通过名称读取出来8.这段代码是通过反射来创建Driver对象,反射就是类的实例化9.在主函数中输入如下,测试方法10.运行之后的结果如下,表示连接成功!

8. 关于.net连接mysql时配置文件要怎么写

最近在写一个.net项目,用的是mysql数据库。因为平时基本不怎么用mysql开发.net项目,于是上网网络了下关于.net引用mysql数据库的案例。基本就是下载mysql数据库的驱动然后dll引入(具体网上有)我按照网上的方法引入了dll,MySql.Data和MySQLDriverCS~~然后引用命名空间的时候用的是MySQLDriverCS。在配置文件中写连接字符串的时候,我是这么写的<add name="connectionString" connectionString="server=192.168.1.247;database=prodmng;User ID=root;Password=root; port=3306" providerName="MySql.Data.MySqlClient" />看起来应该是没错,但是在运行的时候老是报错,首先是报root账号的密码错误,后来,我把密码改成了本地数据库的root账号的密码,结果能连上数据库,而且是本地的数据库!!这说明我配置中写的sever的ip根本没起作用!后来我在网上有找了很久,找到了问题所在!代码如下:<add name="connectionString" connectionString="Location=192.168.1.247;Data Source=prodmng;User ID=root;Password=root; port=3306" providerName="MySql.Data.MySqlClient" />我把server改成location ,database改成Data Source 后,就能连上247服务器的数据库了!!后来,在网上发现有些人是用MySql.Data.MySqlClient这个库的,然后我就试了下这个库。这个哭和之前那个MySQLDriverCS不同的地方在于里面的类名中的sql字母大小写不一样,比如MySql.Data.MySqlClient中的MySqlConnection在MySQLDriverCS中就是MySQLConnection。在引用这个库之后,我发现我之前改过的连接字符串报错了!不存在location这个属性,于是我把连接字符串改成之前那样:<add name="connectionString" connectionString="server=192.168.1.247;database=prodmng;User ID=root;Password=root; port=3306" providerName="MySql.Data.MySqlClient" />然后运行程序,没有问题,能访问数据库!

9. 数据库配置文件怎么填写

一般放置来在配置文件中源按以下方式楼主写的app.config使用Web.config是相同的节点<新增名称=“数据库”的connectionString=“供应商=Microsoft.Jet。OLEDB.4.0;数据源=数据\data.mdb中“的providerName=”System.Data.OleDb“p>程序这样的引用ConfigurationManager中。。的ConnectionStrings[“数据库”]的ConnectionString;注意添加引用

10. linux中连接数据库的配置文件怎么写

linux安装的mysql的配置文件的方法 查找以前是否安装有mysql,使用下面命令: rpm -qa|grep -i mysql 如果显示有如下包则说明已安装mysql mysql-4.1.12-3.RHEL4.1 mysqlclient10-3.23.58-4.RHEL4.1 如果已安装,则需要删除已安装的数据库


赞 (0)