Fork me on GitHub

Since jdbc doesn't support reusing parameters, it seems like it would be smart to just add a declare @x nvarchar(50) = ?; type statements at the top of the queries (if they need to reuse parameters). Anyone see any problems with that?


yes, I would not trust the scoping of those variables


passing in parameters multiple times is nice and simple compared to adding mutable variables that may be connection scoped and passed around through your connection pool


For the db I'm using (SQL Server), there is only one special kind of thing that has connection scope (not normal declares like above). For passing the variable multiple times, I can see it being fine if you can assume it is tiny, but what if you can't? For example, if big json documents are sometimes passed