));Insert dataMysql> insert into testuser (id, name) values (1001, 'Google ');Mysql> insert into testuser (id, name) values (1002, 'kingsoft ');Mysql> insert into testuser (id, name) values (1003, 'Firefox ');
Below is the test code of c ++:
The Code is as follows:
Copy code
# Include # Include # Include Using namespace SQL;Using namespace std;Void RunConnectMySQL (){Mysql: MySQL_Driver * driver;Connection * con;Statement * state;ResultSet * result;// Initialize
Link the database and add data to the WinForm windowUsing System;Using System.Collections.Generic;Using System.ComponentModel;Using System.Data;Using System.Drawing;Using System.Linq;Using System.Text;Using System.Threading.Tasks;Using System.Windows.Forms;Using System.Data.SqlClient; It's important to use namespacesNamespace Freepractice{public partial class Form1:form{Public Form1 (){InitializeComponent ();}private void Butaddcourse_click (object sender, EventArgs e){Get the value of a text bo
() {$this->_link_cons = $this->connect (); return $ This->_link_cons; }//Setting function Kedua Dari Interface public Function Connect () {$this->_link = @mysql_connect (' localhost ', ' Faizal ', ' xxxxxxxxxxx ', ' 3306 ') or Die ($this->error_mysql ()); } //Settiong function Ketiga Dari Interface public Function Error_mysql () {$this->_error = " Masalah Pada koneksi Ke jalur Mysql "; }//Settiong function Keempat Dari Interface public Function db_selected () {$this->_db = mysql_select_db ('
Function Dari Interface public function _ construct () {$ this-> _ Link_Cons = $ this-> connect (); return $ this-> _ Link_Cons;} // Setting Function Kedua Dari Interface publi C function connect () {$ this-> _ link = @ mysql_connect ('localhost', 'faizal', 'xxxxxxxxxxxxxx', '123 ') or die ($ this-> error_mysql ();} // Settiong Function Ketiga Dari Interface public function error_mysql () {$ this-> _ Error = "Masalah Pada Koneksi Ke Jalur Mysql";} // Settiong Function Keempat Dari Interface pub
');
Below is the C + + test code:
The code is as follows
Copy Code
#include #include #include using namespace SQL;using namespace Std;void Runconnectmysql (){Mysql::mysql_driver *driver;Connection *con;Statement *state;ResultSet *result;Initialization driverDriver = Sql::mysql::get_mysql_driver_instance ();Create a linkcon = driver->connect ("http://127.0.0.1:3306", "root", "123");State = Con->createstatement (
*/
Public classJdbcutil {//link address, setting encoding is available and Utf-8
Public StaticString url="Jdbc:mysql://192.168.80.131:3306/db1?useunicode=truecharacterencoding=utf8"; //Database user name
Public StaticString user="Root"; //Database Password
Public StaticString pwd="123456"; /** Link to the database*/
Public StaticConnection getconnection () {Connection con=NULL; Try {
//Load DriverClass.forName ("Com.mysql.jdbc.Driver"); //Create a
Contact Us
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.