Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

spring 5 jdbctemplate query for a single value

public String getStreetNameById(int id) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    String sql = "SELECT STREET_NAME FROM table WHERE ID=?";

    String streetName = (String) jdbcTemplate.queryForObject(
            sql, String.class, id);

    return streetName;
}
Comment

spring 5 jdbctemplate query for a single value

String result = DataAccessUtils.singleResult(
    jdbcTemplate.queryForList(
        "SELECT street_name FROM table WHERE id = :id",
        Collections.singletonMap("id", id),
        String.class
    )
)
Comment

PREVIOUS NEXT
Code Example
Java :: java instantiate a scanner 
Java :: regular expression java 
Java :: how to find sum of the digit of the numbers in java 
Java :: android java show hide keyboard: 
Java :: rock paper scissors java 
Java :: initialize hashmap java 
Java :: how to make popupwindow background blur in android 
Java :: isEmpty java code 
Java :: how to output in java 
Java :: how to get index of arraylist in java 
Java :: android dialog modal 
Java :: android java how to blur an image 
Java :: spring convert page to list 
Java :: spring security logging 
Java :: java loops 
Java :: java array get index 
Java :: flutter unable to find bundled java version 
Java :: Java Access PriorityQueue Elements 
Java :: initializing list in java 
Java :: Implementing the ArrayList Class in java list 
Java :: change short video to byte array android 
Java :: how to use enumUtils in java 
Java :: Number formatting java with locale 
Java :: get SecretKey from String 
Java :: format print java 
Java :: java list remove 
Java :: draw triangle in android studio xml 
Java :: char value java 
Java :: show all spring boot beans 
Java :: jpql spring boot 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =