package com.xxx.pojo;
public class keyTable {
private int id;
private String name;
private String dates;
public keyTable() {
}
public keyTable(int id, String name, String dates) {
this.id = id;
this.name = name;
this.dates = dates;
}
@Override
public String toString() {
return "keyTable{" +
"id=" + id +
", name='" + name + '\'' +
", dates='" + dates + '\'' +
'}';
}
// get set
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDates() {
return dates;
}
public void setDates(String dates) {
this.dates = dates;
}
}
package com.xxx.dao;
import com.xxx.pojo.keyTable;
import java.util.List;
// 接口
public interface keyTableDao {
/*
增加
依据id删除
修改
依据id查询
*/
int AddTable(keyTable keyTable);
int DeleteByIdTable(int id);
int UpdateTable(keyTable keyTable);
List FindById(int id);
}
// 实现
package com.xxx.dao.impl;
import com.xxx.dao.keyTableDao;
import com.xxx.pojo.keyTable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
@Repository("keyTableDao")
public class keyTableDaoImpl implements keyTableDao {
@Resource(name = "JdbcTemplate")
private JdbcTemplate template;
@Override
public int AddTable(keyTable keyTable) {
String sql = "insert into key_table values(?,?,?)";
int result = template.update(sql, keyTable.getId(), keyTable.getName(), keyTable.getDates());
return result;
}
@Override
public int DeleteByIdTable(int id) {
String sql = "delete from key_table where id = ?";
int result = template.update(sql,id);
return result;
}
@Override
public int UpdateTable(keyTable keyTable) {
String name = keyTable.getName();
int id = keyTable.getId();
String sql = "update key_table set name = ? where id = ?";
int result = template.update(sql, name, id);
return result;
}
@Override
public List FindById(int id) {
String sql = "select * from key_table where id = ?";
List query = template.query(sql, new RowMapper() {
@Override
public keyTable mapRow(ResultSet rs, int rowNum) throws SQLException {
keyTable k = new keyTable();
k.setId(rs.getInt(1));
k.setName(rs.getString(2));
k.setDates(rs.getString(3));
return k;
}
},id);
return query;
}
}
6.实现service层
package com.xxx.service;
import com.xxx.pojo.keyTable;
import java.util.List;
// 接口
public interface keyTableService {
/*
增加
依据id删除
修改
依据id查询
*/
int AddTable(keyTable keyTable);
int DeleteByIdTable(int id);
int UpdateTable(keyTable keyTable);
List FindById(int id);
}
package com.xxx.service.impl;
import com.xxx.dao.keyTableDao;
import com.xxx.pojo.keyTable;
import com.xxx.service.keyTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
// 实现类
@Service("keyTableService") // spring帮我创建的实现类
public class keyTableServiceImpl implements keyTableService{
@Autowired // 注入bean
private keyTableDao keyTableDao;
@Override
public int AddTable(keyTable keyTable) {
int result = keyTableDao.AddTable(keyTable);
return result;
}
@Override
public int DeleteByIdTable(int id) {
int result = keyTableDao.DeleteByIdTable(id);
return result;
}
@Override
public int UpdateTable(keyTable keyTable) {
int result = keyTableDao.UpdateTable(keyTable);
return result;
}
@Override
public List FindById(int id) {
List list = keyTableDao.FindById(id);
return list;
}
}
7.测试jdcb是否成功
package com.test;
import com.xxx.pojo.keyTable;
import com.xxx.service.keyTableService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class TestKeyService {
// 增加
@Test
public void AddTableTest(){
ApplicationContext app = new ClassPathXmlApplicationContext("beans.xml");
keyTableService keyTableService = (keyTableService) app.getBean("keyTableService");
keyTable k = new keyTable();
k.setId(3);
k.setName("我是被增加的对象");
k.setDates("2021-12-23");
int result = keyTableService.AddTable(k);
if (result > 0){
System.out.println("执行成功");
} else {
System.out.println("失败了");
}
}
// 依据id删除
@Test
public void DeleteTableTest(){
ApplicationContext app = new ClassPathXmlApplicationContext("beans.xml");
keyTableService keyTableService = (keyTableService) app.getBean("keyTableService");
int result = keyTableService.DeleteByIdTable(111);
if (result > 0){
System.out.println("执行成功");
} else {
System.out.println("失败了");
}
}
// 修改
@Test
public void UpdateTableTest(){
ApplicationContext app = new ClassPathXmlApplicationContext("beans.xml");
keyTableService keyTableService = (keyTableService) app.getBean("keyTableService");
keyTable keyTable = new keyTable();
keyTable.setName("修改了");
keyTable.setId(17);
int result = keyTableService.UpdateTable(keyTable);
if (result > 0){
System.out.println("执行成功");
} else {
System.out.println("失败了");
}
}
// 依据id查询
@Test
public void FindAddTableTest(){
ApplicationContext app = new ClassPathXmlApplicationContext("beans.xml");
keyTableService keyTableService = (keyTableService) app.getBean("keyTableService");
List list = keyTableService.FindById(1);
for (keyTable k:list) {
System.out.println(k);
}
}
}
在平时工作中,难免会遇到把 XML 作为数据存储格式。面对目前种类繁多的解决方案,哪个最适合我们呢?在这篇文章中,我对这四种主流方案做一个不完全评测,仅仅针对遍历 XML 这块来测试,因为遍历 XML 是工作中使用最多的(至少我认为)。 预 备 测试环境: AMD 毒龙1.4G OC 1.5G、256M DDR333、Windows2000 Server
Netty 3.x的user guide里FrameDecoder的例子,有几个疑问:
1.文档说:FrameDecoder calls decode method with an internally maintained cumulative buffer whenever new data is received.
为什么每次有新数据到达时,都会调用decode方法?
2.Dec
hive> select * from t_test where ds=20150323 limit 2;
OK
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
问题原因: hive堆内存默认为256M
这个问题的解决方法为:
修改/us
Simply do the following:
I. Declare a global variable:
var markersArray = [];
II. Define a function:
function clearOverlays() {
for (var i = 0; i < markersArray.length; i++ )
Quick sort is probably used more widely than any other. It is popular because it is not difficult to implement, works well for a variety of different kinds of input data, and is substantially faster t