You may just initialize the PreparedStatement once and cache it while the app is running. It should be available for use as long as the Cassandra cluster is up.
Using the statement from multiple threads is fine (as long as you don't modify it throught setXXX()
methods). When you call bind(), the code underneath only reads the PreparedStatement and then creates a new instance of BoundStatement() which the caller thread is then free to mutate.
Here is the source code, if you're curious (search for bind()
).