Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 可以编辑您的答案)xmlns:util=”http://www.springframework.org/schema/util“xsi:schemaLocation=”http://www.springframework.org/schema/beans _Java_Sql_Spring Jdbc - Fatal编程技术网

Java 可以编辑您的答案)xmlns:util=”http://www.springframework.org/schema/util“xsi:schemaLocation=”http://www.springframework.org/schema/beans

Java 可以编辑您的答案)xmlns:util=”http://www.springframework.org/schema/util“xsi:schemaLocation=”http://www.springframework.org/schema/beans ,java,sql,spring-jdbc,Java,Sql,Spring Jdbc,可以编辑您的答案)xmlns:util=”http://www.springframework.org/schema/util“xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/util http://www


可以编辑您的答案)
xmlns:util=”http://www.springframework.org/schema/util“xsi:schemaLocation=”http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 			http://www.springframework.org/schema/util  http://www.springframework.org/schema/util/spring-util-3.1.xsd“>
FAI(供任何人参考);从Spring 4.0.3开始,所有这些方法(
executeSqlScript
readScript
包含QLScriptDelimiters
splitSqlScript
)标记为已弃用;从Spring 5.0开始,它们都已被移动到或替换为提供的功能。一个干净的解决方案。您可以将其与Spring名称ParameterJDBCTemplate一起使用,以使代码更具可读性。它允许您使用命名参数,如Hibernate(例如,where dt>=:startDt),正确的字符串是什么如果我的yml文件位于“/resources/querys”中,“dir_with_yml_files”?
queries.myquery = select \
foo, bar \
from mytable \
where baz > 10
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">

<properties>
<entry key="getPersonById">
    <![CDATA[
        Select Name From Person 
        Where Id =?     
    ]]>

</entry>    
<entry key="getPersonBySSN">
    <![CDATA[

    ]]>
</entry>

</properties>
<bean id="queryProps" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
    <property name="locations" value="classpath:/queries.xml" />
</bean>
<bean id="myDAO" class="com.xyz.dao.MyDAOImpl">
  <property name="queryProps" ref="queryProps" />
</bean>
 private Properties queryProps;
 String query = queryProps.getProperty("getPersonById");
xmlns:util="http://www.springframework.org/schema/util
<util:properties id="sqls" location="classpath:oracle/sqls.xml" />
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <comment>Employee Queries</comment>
    <entry key="employee.insert">
        INSERT
        INTO EMPLOYEE
          (
            ID,
            NAME,
            AGE,
            DEPARTMENT
          )
        VALUES
          (
            EMPLOYEE_SEQ.NEXTVAL,
            ?,
            ?,
            ?
          )
    </entry>
</properties>
@Autowired
@Qualifier("sqls")
private Properties sqls;
String sql = sqls.getProperty("employee.insert");
selectSomething: >
  SELECT column1, column2 FROM SOMETHING

insertSomething: >
  INSERT INTO SOMETHING(column1, column2)
  VALUES(1, '1')
anotherSelect: <
  SELECT column1 FROM SOMETHING
  WHERE column2 IN (
    SELECT * FROM SOMETHING_ELSE
  )
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.FileUtils;
import java.io.FileReader;

import org.yaml.snakeyaml.Yaml;
import java.io.File;
import java.io.FileNotFoundException;

public class SQLReader {
  private Map<String, Map> sqlQueries = new HashMap<String, Map>();

  private SQLReader() {
    try {
      final File sqlYmlDir = new File("dir_with_yml_files");
      Collection<File> ymlFiles = FileUtils.listFiles(sqlYmlDir, new String[]{"yml"}, false);
      for (File f : ymlFiles) {
        final String fileName = FilenameUtils.getBaseName(f.getName());
        Map ymlQueries = (Map)new Yaml().load(new FileReader(f));
        sqlQueries.put(fileName, ymlQueries);
      }
    }
    catch (FileNotFoundException ex) {
      System.out.println("File not found!!!");
    }
  }
}