java - Named parameters in JDBC -


are there named parameters in jdbc instead of positional ones, @name, @city in ado.net query below?

select * customers name=@name , city = @city 

jdbc not support named parameters. unless bound using plain jdbc (which causes pain, let me tell that) suggest use springs excellent jdbctemplate can used without whole ioc container.

namedparameterjdbctemplate supports named parameters, can use them that:

 namedparameterjdbctemplate jdbctemplate = new namedparameterjdbctemplate(datasource);   mapsqlparametersource paramsource = new mapsqlparametersource();  paramsource.addvalue("name", name);  paramsource.addvalue("city", city);  jdbctemplate.queryforrowset("select * customers name = :name , city = :city", paramsource); 

Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -