设为首页 加入收藏

TOP

对象保存进MySQL数据库,从MySQL中读取出对象信息的源码(二)
2017-11-15 09:15:15 】 浏览:169
Tags:对象 保存 MySQL 数据库 取出 信息 源码
// TODO Auto-generated catch block e.printStackTrace(); } return null; } }

测试类:

将对象添加进数据库:

package com.test;

import com.bean.User;
import com.utils.DBUtils;

public class Test1 {

	public static void main(String[] args) {

		DBUtils utils = new DBUtils();

		User user = new User("小明", "123456");

		if (utils.addObject(user) != 0) {

			System.out.println("添加成功!");

		}

	}

}
\

从数据库中读取出对象信息:

package com.test;

import com.bean.User;
import com.utils.DBUtils;

public class Test1 {

	public static void main(String[] args) {

		DBUtils utils = new DBUtils();

		User user = utils.getObj("小明");

		System.out.println(user.toString());

	}

}


\

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇SQLServer2008创建和修改数据表教.. 下一篇MongoDB安装和配置WINDOWS服务时1..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目