<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                配置文件 ``` <!-- spring jdbc datasource --> <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"> <property name="driverClassName" value="${driver}"></property> <property name="url" value="${url}"></property> <property name="username" value="${uname}"></property> <property name="password" value="${password}"></property> </bean> <!-- spring jdbc template --> <bean id="jt" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"></property> </bean> ``` java類實現 ``` import java.sql.Date; import java.sql.ResultSet; import java.sql.SQLException; import java.util.List; 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 com.neuedu.model.po.Student; @Repository public class StudentDAO { @Autowired private JdbcTemplate jt; public void addStudent() { String sql = "insert into student values(null,?,?,?,?,?,?)"; Object[] args = {"123","feiyy",Date.valueOf("1991-1-1"),"女","計算機",1003}; //執行操作 jt.update(sql, args); } public List<Student> getUsers(Student s) { String sql = "select * from student where stuname = ?"; Object[] args = {s.getStuname()}; return jt.query(sql, args,new RowMapper<Student>(){ @Override public Student mapRow(ResultSet rs, int rowNum) throws SQLException { Student s = new Student(); s.setStuno(rs.getLong("stuno")); s.setStuname(rs.getString("stuname")); s.setBirthday(rs.getDate("birthday")); return s; } }); } public Student getUser(long stuno) { String sql = "select * from student where stuno = ?"; Object[] args = {stuno}; return jt.queryForObject(sql, args, new RowMapper<Student>(){ @Override public Student mapRow(ResultSet rs, int rowNum) throws SQLException { Student s = new Student(); s.setStuno(rs.getLong("stuno")); s.setStuname(rs.getString("stuname")); s.setBirthday(rs.getDate("birthday")); return s; }}); } } ``` 測試類的實現 ``` public class TestSpringJDBC { @Test public void testUpdate() { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); StudentDAO dao = ctx.getBean(StudentDAO.class); dao.addStudent(); } @Test public void testQueryList() { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); StudentDAO dao = ctx.getBean(StudentDAO.class); Student condition = new Student(); condition.setStuname("湯姆"); List<Student> students = dao.getUsers(condition); for(Student s: students) { System.out.println(s.getStuno()+"\t"+s.getStuname()+"\t"+s.getBirthday()); } } @Test public void testQueryOne() { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); StudentDAO dao = ctx.getBean(StudentDAO.class); Student s = dao.getUser(2019040409999L); System.out.println(s.getStuno()+"\t"+s.getStuname()+"\t"+s.getBirthday()); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看