mysql连接串怎么写 MySQL连接串

java连接Mysql的连接字符串怎么写的

import java.sql.*;

成都创新互联公司专注于博乐企业网站建设,成都响应式网站建设公司,商城网站制作。博乐网站建设公司,为博乐等地区提供建站服务。全流程按需网站设计,专业设计,全程项目跟踪,成都创新互联公司专业和态度为您提供的服务

public class SqlUtil

{

public static void main(String[] args)

{

try

{

String url="jdbc:mysql://localhost/mydb";

String user="root"; //用户名

String pwd="123456"; //密码

//加载驱动,这一句也可写为:Class.forName("com.mysql.jdbc.Driver");

Class.forName("com.mysql.jdbc.Driver").newInstance();

//建立到MySQL的连接

Connection conn = DriverManager.getConnection(url,user, pwd);

//执行SQL语句

Statement stmt = conn.createStatement();//创建语句对象,用以执行sql语言

ResultSet rs = stmt.executeQuery("select * from student");

//处理结果集

while (rs.next())

{

String name = rs.getString("name");

System.out.println(name);

}

rs.close();//关闭数据库

conn.close();

}

catch (Exception ex)

{

System.out.println("Error : " + ex.toString());

}技术问题可到itjob技术群交流

}

}

C#连接mysql数据库的字符串怎么写?

首先呢,去Mysql官网下载MySql.Data.dll,然后添加引用

using MySql.Data.MySqlClient;

然后使用连接字符串的时候,使用以下代码:

MySqlConnectionStringBuilder s = new MySqlConnectionStringBuilder();

s.Server = "192.168.0.100";

s.Port = 3306; //mysql端口号

s.Database = "dbName";

s.UserID = "root";

s.Password = "root";

s.CharacterSet = "latin1";

MySqlConnection mcon = new MySqlConnection(s.ConnectionString);

其他的也要用mysql的,比如MySqlCommand等等。有疑问可以追问~

怎么在mysql里做字符串连接

在mysql里做字符串连接主要用到“CONCAT”函数,主要使用方法如下:

这样查询出来的结果,就把原来ts_test里面的save_path和save_name组装到thumb字段里面!

c#连接到mysql 的连接字符串怎么写

ODBC DSN

ODBC -- MyODBC Driver -- local database

ODBC -- MyODBC Driver -- remote database

ODBC -- MySQL ODBC 3.51 Driver

OleDb

.NET DataProvider from CoreLab

// ODBC DSN

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString =

"Dsn=DsnName;" +

"Uid=UserName;" +

"Pwd=Secret;";

conn.Open();

// ODBC -- MyODBC Driver -- local database

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString =

"Driver={MySql};" +

"Server=localhost;" +

"Option=16834;" +

"DataBase=DataBaseName;"

conn.Open();

// ODBC -- MyODBC Driver -- remote database

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString =

"Driver={MySql};" +

"Server=db.domain.com;" +

"Option=131072;" +

"Port=3306;" +

"Stmt=;" +

"DataBase=DataBaseName;" +

"Uid=UserName;" +

"Pwd=Secret;"

conn.Open();

// ODBC -- MySQL ODBC 3.51 Driver

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString =

"Driver={MySql ODBC 3.51 Driver};" +

"Server=ServerName;" +

"Option=16834;" +

"Port=3306;" +

"Stmt=;" +

"DataBase=DataBaseName;" +

"Uid=UserName;" +

"Pwd=Secret;"

conn.Open();

// or

using System.Data.Odbc;

OdbcConnection conn = new OdbcConnection();

conn.ConnectionString =

"DRIVER={MySql ODBC 3.51 Driver};" +

"SERVER=ServerName;" +

"DATABASE=DataBaseName;" +

"USER=UrerName;" +

"PASSWORD=Secret;"

conn.Open();

// OleDb

using System.Data.OleDb;

OleDbConnection conn = new OleDbConnection();

conn.ConnectionString =

"Provider=MySqlProv;" +

"Data Source=ServerName;" +

"User id=UserName;" +

"Password=Secret;"

conn.Open();

// .NET DataProvider from CoreLab

using CoreLab.MySql;

MySqlConnection conn = new MySqlConnection();

conn.ConnectionString =

"Host=ServerName;" +

"DataBase=DataBaseName;" +

"Protocol=TCP;" +

"Port=3306;" +

"Direct=true;" +

"Compress=false;" +

"Pooling=true;" +

"Min Pool Size=0;" +

"Max Pool Size=100;" +

"Connection Lifetime=0;" +

"User id=UserName;" +

"Password=Secret;" +

conn.Open();


新闻标题:mysql连接串怎么写 MySQL连接串
地址分享:http://azwzsj.com/article/hjjiod.html