有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (2) 个答案

  1. # 1 楼答案

    这在很大程度上取决于您使用的数据库。但这里有一个例子for Oracle。通常,您需要一个Connection、一个Statement和一个ResultSet

  2. # 2 楼答案

    这就是我想要的答案/代码:

    public void runUserQuery(final String userString,final int userInput) 抛出IllegalArgumentException,NamingException{ 系统出来println(“正在执行”+userString+“”+userInput); 类NewDao扩展了JdbcDaoSupport{

            public NewDao() throws IllegalArgumentException, NamingException {
                JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
                bean.setJndiName("<JNDI Name>");
                bean.afterPropertiesSet();
                DataSource dataSource = (DataSource) bean.getObject();
                setDataSource(dataSource);
    
    
            }
    
            public void executeQueryMultiple() {
                int index = userInput;
                while (index > 0) {
                    this.getJdbcTemplate().execute(userString);
                    index ;
                }
            }
    
        }
        ;
        NewDao dao = new NewDao();
    
        dao.executeQueryMultiple();
    
    }
    

    不幸的是,我没能让你们理解,结果投了反对票D