我会改的嘛,我又不是一翘不通。另外,我只想看看代码怎么写的,我对SqlServer和Oracle比较熟悉。

解决方案 »

  1.   

    import java.io.*;
    import java.sql.*;public class HelloWorld { public static void main(String[] args) {
    System.out.println("hello world");
    try
    {
    Class.forName("org.gjt.mm.mysql.Driver");
    }
    catch (ClassNotFoundException e)
    {
    System.out.println("Class not found");
    e.printStackTrace();
    } try
    {
    Connection myConn =
    DriverManager.getConnection("jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=ISO8859_1");
    Statement stmt=myConn.createStatement();
    ResultSet rs=stmt.executeQuery("select * from mytable");
    while (rs.next())
    {
    System.out.println(rs.getInt(1));
    rs.next();
    }

    }
    catch (SQLException e)
    {
     System.out.println("ERROR");
     e.printStackTrace(); }

    }
    }
      

  2.   

    MYSQL *pConn;
    pConn = mysql_init(NULL);
    if (pConn != mysql_real_connect(pConn, "localhost", "userid", "password", "database", 0))
     {
     MessageBox(hwnd, mysql_error(pConn), "Error", MB_OK);
     exit(1);
     }
    CString strSQL = "SELECT * FROM TABLE1";
    if (mysql_real_query(pConn, strSQL.GetBuffer(), strSQL.GetLength()))
     {
     MessageBox(hwnd, mysql_error(pConn), "Error", MB_OK);
     exit(1);
     }MYSQL_RES *pRes = mysql_store_result(pConn);
    if (!pRes)
     {
     MessageBox(hwnd, mysql_error(pConn), "Error", MB_OK);
     mysql_close(pConn);
     exit(1);
     }
    MYSQL_ROW row;
    CDC *pDC = GetDC();
    int y = 0;
    while (row = mysql_fetch_row(pRes))
    {
     pDC->TextOut(0, y, row[0]);
     y += 20;
    }
    ReleaseDC(pDC);
    mysql_free_result(pRes);
    mysql_close(pConn);