首页 > 编程知识 正文

mysql数据库读写操作源代码(mysql数据库读写操作源代码查询)

时间:2023-12-09 23:05:02 阅读:313813 作者:QYPL

本文目录一览:

  • 1、CentOS5.3 - mysql-6.0.10-alpha 源代码和设置
  • 2、你有一个简单的数据库的源代码吗?最好用Java实现的...
  • 3、如何下载mysql数据库源代码

CentOS5.3 - mysql-6.0.10-alpha 源代码和设置

1,下载mysql数据库 源代码 : mysql-6.0.10-alpha.tar.gz 2, 解压 文件比较多,解压也一段时间。 src]# tar vxzf mysql-6.0.10-alpha.tar.gz 3, 进入目录进行 - 配置,编译,安装 ]# cd mysql-6.0.10-alpha 配置生成 makefile 文件 ]# ./configure --sysconfdir=/etc checking for termcap functions library... configure: error: No curses/termcap library found 出现错误,也就是生成 makefile 文件出错了。 [root@localhost mysql-6.0.10-alpha]# make make: *** No targets specified and no makefile found. Stop. 如果你硬要输入 make 命令是不行的,因为 makefile 根本没有生成成功。 解决办法: 我们加入 --with-named-curses-libs=/usr/lib/libncursesw.so.5 进行生成 makefile ./configure --sysconfdir=/etc --with-named-curses-libs=/usr/lib/libncursesw.so.5 Thank you for choosing MySQL! 看到这句话,生成 makefile 成功了。 下面进行make编译: 需要的时间比较长。 ]# make 编译安装虽然花费的时间比较长,但是它应该可以适合任何一个发行版本的 Linux,编译的中途过程我就不播放视频出来了,截断一部分。我现在已经编译完成。 make[1]: Leaving directory `/opt/mysql-6.0.10-alpha/sql-bench' Making all in win make[1]: Entering directory `/opt/mysql-6.0.10-alpha/win' make[1]: Nothing to be done for `all'. make[1]: Leaving directory `/opt/mysql-6.0.10-alpha/win' 最后进行安装 ]# make install 编译安装完毕,有时候需要很长时间,如何判断是否死机? 注意观察主机的硬盘灯,编译安装时候 硬盘灯是一闪一闪的,有数据读取。 下面拷贝配置文件 ]# cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf 以后配置mysql ,就修改 /etc/my.cnf 即可 4, 初始化数据库 # useradd -d /usr/local/var mysql # su - mysql $ /usr/local/bin/mysql_install_db 初始化出现错误。 Installing MySQL system tables... 090518 7:16:41 [ERROR] /usr/local/libexec/mysqld: unknown option '--skip-federated' 090518 7:16:41 [ERROR] Aborting 090518 7:16:41 [Note] /usr/local/libexec/mysqld: Shutdown complete 我们解决办法是,先 删掉 /usr/local/var 下的 mysql 文件夹 rm -rf /usr/local/var/mysql 然后修改 vi /etc/my.cnf 找到skip-federated 注释掉 ,也就是改成 ####skip-federated 然后保存退出 su - mysql 用会 mysql 身份, 来重新初始化 /usr/local/bin/mysql_install_db 这次成功了吧,没有出现错误信息。 5, 启动服务器 [mysql@localhost var]$ /usr/local/bin/mysqld_safe 现在成功了, 用 netstat -tnl 看到 3306 熟悉的 mysql默认端口 6, 登陆测试 [mysql@localhost local]$ mysql -u root 成功的话, 出现 mysql mysqls mysqlq 可以使用 show databases; 一般,如果你是编译安装mysql ,建议你像我下面的做法 提升为 root 用户, su - cp /usr/local/share/mysql/mysql.server /etc/init.d/mysqld mysql 关闭的命令为:/etc/init.d/mysqld stop [root@localhost ~]# /etc/init.d/mysqld stop Shutting down MySQL.090518 07:26:41 mysqld_safe mysqld from pid file /usr/local/var/localhost.localdomain.pid ended SUCCESS! 就会显示 关闭成功。 mysql 启动的命令为:/etc/init.d/mysqld start [root@localhost ~]# /etc/init.d/mysqld start Starting MySQL. SUCCESS! 下面修改 服务器启动时候,就自动运行 mysql 6.0 vi /etc/rc.d/rc.local 我把它运行在 tomcat 前面, 然后保存退出。 ##################### 分隔 ###################### --查看数据库的字符集 show variables like 'character_set_%'; show variables like 'collation_%'; 13:15 浏览(587) 评论(0) 分类: CentOS 2009-07-21 缩略显示 CentOS5.3 编译 mod_jk 1.2.15 链接器 整合apache httpd 和 tomcat关键字: centos mod_jk 现在我们来做一个整合,也就是当访问 apache 80 端口时候 遇到 jsp 文件也可以正常访问。 如果不整合, 你的apache 80 是不能运行jsp文件的, 只能使用8080端口,也就是tomcat 来访问。 如何整合呢 ? 要借助一个叫做 apache tomcat 的链接器。 下面是官方网站的下载地址,目前为止最新版是 1.2.15。。。 文章最后我会把这个工具提供下载,如果官方网站太慢的话。 首先下载 jakarta-tomcat-connectors-1.2.15-src.tar.gz 到服务器 解压 ]# tar xzvf jakarta-tomcat-connectors-1.2.15-src.tar.gz 注意是进入: jk/native 这个目录 ]# cd jakarta-tomcat-connectors-1.2.15-src/jk/native 请确认你的 apache 的 apxs 文件位置 native]# ./configure --with-apxs=/usr/local/apache2/bin/apxs 编译生成mod_jk native]# make 拷贝编译完成生成的 mod_jk.so 文件, 这里也是要注意你的apache modules 目录位置 native]# cp ./apache-2.0/mod_jk.so /usr/local/apache2/modules/ =============================================== 修改apache 配置文件 # vi /etc/httpd.conf 在DirectoryIndex中添加 index.jsp IfModule dir_module DirectoryIndex index.html index.jsp /IfModule 增加关于加载mod_jk的语句: LoadModule jk_module modules/mod_jk.so Include /usr/local/apache2/conf/mod_jk.conf 添加以下内容( 添加的时候去掉注释,可能文件不能显示中文 ): ###### 指出mod_jk模块工作所需要的工作文件workers.properties的位置 JkWorkersFile /usr/local/apache2/conf/workers.properties ###### Where to put jk logs JkLogFile /usr/local/apache2/logs/mod_jk.log ###### Set the jk log level [debug/error/info] JkLogLevel info ###### Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" ###### JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories ###### JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" ###### 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理 JkMount /servlet/* worker1 JkMount /*.jsp worker1 JkMount /*.do worker1 把一些注释去掉吧,只些一些起作用的语句上去。保存退出。 =================================================== 在/usr/local/apache2/conf/ 下面 建立两个配置文件mod_jk.conf和workers.propertie 注意: ( 如果没有 conf 目录,可以建立,因为我安装时指定把 httpd.conf 放在 /etc 下的,就没有 conf 目录了 ) # vi mod_jk.conf 添加以下内容( 添加的时候去掉注释,可能文件不能显示中文 ): ###### 指出mod_jk模块工作所需要的工作文件workers.properties的位置 JkWorkersFile /usr/local/apache2/conf/workers.properties ###### Where to put jk logs JkLogFile /usr/local/apache2/logs/mod_jk.log ###### Set the jk log level [debug/error/info] JkLogLevel info ###### Select the log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" ###### JkOptions indicate to send SSL KEY SIZE, JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories ###### JkRequestLogFormat set the request format JkRequestLogFormat "%w %V %T" ###### 将所有servlet 和jsp请求通过ajp13的协议送给Tomcat,让Tomcat来处理 JkMount /servlet/* worker1 JkMount /*.jsp worker1 JkMount /*.do worker1 ------------------------------------------------------------ # vi workers.properties 添加以下内容: ####### Defining a worker named worker1 and of type ajp13 worker.list=worker1 ####### Set properties for worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009 worker.worker1.lbfactor=50 worker.worker1.cachesize=10 worker.worker1.cache_timeout=600 worker.worker1.socket_keepalive=1 worker.worker1.socket_timeout=300 ------------------- 我的tomcat 配置文件路径: /usr/local/tomcat/conf/server.xml 最后编辑Tomcat的配置文件server.xml,在 Host 段中加入: Context path="" docBase="/usr/local/apache2/htdocs" debug="0" reloadable="true" crossContext="true"/ 重新启动Apache和Tomcat。。。 [root@localhost bin]# ./shutdown.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jdk1.7.0 [root@localhost bin]# ./startup.sh Using CATALINA_BASE: /usr/local/tomcat Using CATALINA_HOME: /usr/local/tomcat Using CATALINA_TMPDIR: /usr/local/tomcat/temp Using JRE_HOME: /usr/java/jdk1.7.0 # /usr/local/apache2/bin/apachectl stop # /usr/local/apache2/bin/apachectl start 刚才我在修改 httpd.conf 可能写入了一些多余信息 导致apache配置文件出错,我注释就可以了。 在/usr/local/apache2/htdocs/ 下 删掉 index.html 建立一个index.jsp , 写入一些简单的内容: % out.println( "Hello " ); % 用浏览器访问服务器 ,看到正确的页面了。 说明apache 遇到jsp页面 ,它可以提交给 tomcat 去处理。。。 18:21 浏览(315) 评论(0) 分类: CentOS 2009-07-21 缩略显示 centos“You don't have permission to access /index.html on this server.”关键字: centos Forbidden You don't have permission to access /index.html on this server. 开始我以为我配置出错,花半天时间都没有搞定,今天终于搞定了. 原因:index.html是用root用户建的文件,apache权限不够。 解决方法:更改文件权限;chmod 755 index.html 17:09 浏览(498) 评论(0) 分类: CentOS 2009-07-17 缩略显示 CentOS5.3 编译安装 apache 2.2.11 web服务器(httpd-2.2.11.tar.gz)关键字: centos apache (现检测是否已经安装apapche,如果有的话请卸载后重新安装) 1, 首先你必须下载 : httpd-2.2.11.tar.gz 当然你也可以到官方 上下载。 2, 解压 src]# tar vxzf httpd-2.2.11.tar.gz 3, 进入目录 # cd httpd-2.2.11 httpd-2.2.11]# ./configure --sysconfdir=/etc --enable-ssl --enable-modules 配置文件放在 /etc 下 no SSL-C headers found configure: error: ...No recognized SSL/TLS toolkit detected 没有ssl 我们,生成makefile 文件失败,以后再安装 openssl 也可以 httpd-2.2.11]# ./configure --sysconfdir=/etc --enable-modules 好,这次没有发现什么错误, --enable-modules 这个强烈建议加上, 也就是说 以后apache 可以添加其他的模块,方便很多。 下面进行编译,make编译 需要一定的时间,不过比起编译mysql要快些。 httpd-2.2.11]# make 下面进行安装 httpd-2.2.11]# make install 安装完成了。。。 4, 启动服务 测试一下吧。 ]# /usr/local/apache2/bin/apachectl start # netstat -tnl 可以看到 80 端口,说明apache启动了。 tcp 0 0 :::80 :::* LISTEN 打开浏览器进行访问吧。 # ifconfig 查看 Linux 服务器ip地址。 inet addr:192.168.138.128 看到It works! 说明正常工作了 cd /usr/local/apache2/ 可以看到 htdocs 就是 web 服务器的 目录所在 你可以想我这样 vi test.html 上面写一些信息,然后进行访问。 让Apache 自动启动 # echo "/usr/local/apache2/bin/apachectl start " /etc/rc.local (或者手动在/etc/rc.d/rc.local中设置) 好,然后重启服务器,就可以发现 apache 自动启动了

你有一个简单的数据库的源代码吗?最好用Java实现的...

class ConnectionProvider{

private static String JDBC_DRIVER;

private static String DB_URL;

private static String DB_USER;

private static String DB_PASSWORD;

public ConnectionProvider()

{

JDBC_DRIVER = "com.mysql.jdbc.Driver"

DB_URL = "jdbc:mysql://localhost:3306/u-disk";

DB_USER = "root";

DB_PASSWORD = "root"

};

public Connection getConnection()

{

try {

Class.forName(JDBC_DRIVER);

} catch (Exception e) {

System.out.println("驱动文件路径有误!");

}

}

Connection con = null;

try {

con = DriverManager.getConnection(DB_URL, DB_USER,

DB_PASSWORD);

} catch (SQLException e) {

System.out.println("数据库连接建立异常!n@shy2850@" + e.getMessage() +

e.getCause());

}

System.out.println("得到连接:Connection " + ConnectionPool.connections.size() + 1);

return new ConnectionImpl(con);

}

}

可以使用这个包装的数据库连接数据源在DAO工具类中使用:

package com.jdbc;

import java.sql.*;

/**课题:封装数据库的增删改查的工具类的实现。

*

* 假设相关数据库的表结构如下:

* 表名:user

* 列名及属性:id(int 自增),name(varchar(20)),tele(char(12)),birthday(date)

* @author shy2850

*/

public class UserDAO {

Connection conn;

public UserDAO(Connection conn) {

this.conn = conn;

}

public int save(User user) throws SQLException {

String sql = "insert into user values(0,?,?,?)";

PreparedStatement pstmt = conn.prepareStatement(sql);

pstmt.setString(1, user.getName());

pstmt.setString(2, user.getTele());

pstmt.setDate(3, user.getBirthday());

int n = pstmt.executeUpdate();

pstmt.close();

return n;

}

public int delete(User user) throws SQLException{

String sql = "delete from user where id = "+user.getId();

Statement stmt = conn.createStatement();

int n = stmt.executeUpdate(sql);

stmt.close();

return n;

}

public int update(User user) throws SQLException{

String sql = "update user set name=?, tele=?, birthday=? where id = "+user.getId();

PreparedStatement pstmt = conn.prepareStatement(sql);

pstmt.setString(2, user.getName());

pstmt.setString(3, user.getTele());

pstmt.setDate(4, user.getBirthday());

int n = pstmt.executeUpdate(sql);

pstmt.close();

return n;

}

public User getUser(Integer id) throws SQLException{

String sql = "select * from user where id = " + id;

Statement stmt = conn.createStatement();

ResultSet rs = stmt.executeQuery(sql);

User user = getUserFromResultSet(rs);

rs.close();

stmt.close();

return user;

}

static User getUserFromResultSet(ResultSet rs) throws SQLException{

Integer id = rs.getInt("id");

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

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

Date birthday = rs.getDate("birthday");

return new User(id, name, tele, birthday);

}

}

/**

* 构建数据库表的java类映射

*/

class User{

private Integer id;

private String name;

private String tele;

private Date birthday;

public User() {

}

public User(Integer id, String name, String tele, Date birthday) {

super();

this.id = id;

this.name = name;

this.tele = tele;

this.birthday = birthday;

}

public Integer getId() {

return id;

}

public void setId(Integer id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getTele() {

return tele;

}

public void setTele(String tele) {

this.tele = tele;

}

public Date getBirthday() {

return birthday;

}

public void setBirthday(Date birthday) {

this.birthday = birthday;

}

}

如何下载mysql数据库源代码

mysql官方网站就有呀:,选择source

code

或者你到这个网站上去下载:,到这个网址,右边有个查看讲义资料,那个里面就有

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。