我会改的嘛,我又不是一翘不通。另外,我只想看看代码怎么写的,我对SqlServer和Oracle比较熟悉。
解决方案 »
- SQL语句构建的问题,
- 我想模拟个mysql cluster,但是官网上为啥找不到mysql-max下载呢,是不是不能下了现在?
- 如何进行MySQL查询的效率分析?
- 【求助】简单触发器问题
- mysql5.0的存储过程
- Lost connection to MySQL server during query
- 存储过程 所有的分都在这里了
- update 语法问题
- 求条SQL语句
- 两个线程分别对应两个数据库连接, 为什么同时select消耗时间成倍增长?
- 如何在postgres中定义事务?
- 新手问题,vc 编译Mysql的例子程序时提示,提示Cannot open include file: 'my_alloc.h',在线等,立刻结贴
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(); }
}
}
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);