MYSQL
|
连接 |
driver="com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/datebase";
Class.forName(driver);
Connection conn = DriverManager.getConnection(url, user, password);
|
执行 |
String sql = "insert into user(name) values(?)";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, username);
ps.executeUpdate();
|
返回结果集 |
ResultSet rs = ps.executeQuery();
|
|
|
|
string sqlstr = "select * from manavatar";
MySQLConnection DBConn = new MySQLConnection(new MySQLConnectionString("192.168.0.13", "flashdata", "root", "root", 3306).AsString);
DBConn.Open();
//MySQLDataAdapter myadap = new MySQLDataAdapter(sqlstr, conn);
MySQLCommand DBComm = new MySQLCommand(sqlstr,DBConn);
MySQLDataReader DBReader = DBComm.ExecuteReaderEx();
MySQLDataAdapter DTAdapter = new MySQLDataAdapter(sqlstr,DBConn);
DataSet myDataSet = new DataSet();
DTAdapter.Fill(myDataSet,"manavatar");
|
连接 |
$conn=mysql_connect($db_server,$db_user_name,$db_user_password);
$flag=mysql_select_db($db_name,$conn);
|
执行 |
$result=mysql_query($sql); |
返回结果集 |
|
|
|
|
MSSQL
|
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
url = "jdbc:sqlserver://localhost:1433;databaseName=datebase";
|
连接 |
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = "Integrated Security=true;Initial Catalog=Northwind;Data Source=.\\SQLExpress";
dataConnection.Open();
|
执行 |
SqlCommand dataCommand = new SqlCommand();
dataCommand.Connection = dataConnection;
dataCommand.CommandText =
"SELECT OrderID, OrderDate, " +
"ShippedDate, ShipName, ShipAddress, ShipCity, " +
"ShipCountry ";
dataCommand.CommandText +=
"FROM Orders WHERE CustomerID='" +
customerId + "'";
|
返回结果集 |
SqlDataReader dataReader = dataCommand.ExecuteReader(); |
|
|
|
$conn=@mssql_connect($db_server,$db_user_name,$db_user_password);
@mssql_select_db($db_name,$conn);
$result=mysql_query($sql);
|
ORACLE
|
driver = "oracle.jdbc.driver.OracleDriver";
url = "jdbc:oracle:thin:@localhost:1521:datebase";
|
OracleConnection
OracleCommand
OracleDataReader
|
$conn=Ora_Logon("user@TNSNAME","password"); |