I am building an API with Spring and JDBC. I now ran into a problem where the JDBC query would not return anything, even though the same query in SQL Developer returns data.
This is my method in java:
public Standardtexte getStandardtexte(String kurztext)
{
Standardtexte standardtexte = new Standardtexte();
standardtexte.kurztext = kurztext;
standardtexte.schluessel = jdbc.query("select schluessel, langtext from hb_standardtexte where kurztext = ?", (rs, rowNum) -> {
Schluessel s = new Schluessel();
s.schluessel = StringUtils.trimToEmpty(rs.getString(1));
s.langtext = StringUtils.trimToEmpty(rs.getString(2));
return s;
}, kurztext);
return standardtexte;
}
I am trying this request in Postman: localhost:8080/standardtexte?kurztext=KOELUNG
but getting no useful result:
{
"kurztext": "KOELUNG",
"schluessel": []
}
When I try the same query in SQL Developer:
select schluessel, langtext from hb_standardtexte where kurztext = 'KOELUNG';
I get this result: Result table image
Can someone help me / explain why this is happening?
I also have tried it with other parameters for kurztext: The weird thing: other parameters work.
Best Answer
Make sure you
COMMIT
your data.In Oracle, if you do not
COMMIT
then only the session where the the data was created can see the uncommitted data and other sessions, even those belonging to the same user, will never see that uncommitted data.For example, the behaviour can be explained:
COMMIT
the data or close the session.COMMIT
the data in SQL Developer.