Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:00:24+00:00 2026-05-25T13:00:24+00:00

When i open a JDBC connection to a MySQL database i want to set

  • 0

When i open a JDBC connection to a MySQL database i want to set some database server variable, so for example every time that a connection is established i want to set the variable sqlmode with this value :

SET sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT';

for enabling pipe string concatenation …

I have to send this parameter in a query statement or can i set this parameter directly on the JDBC Connection ? Is there a property on the JDBC connection that allow set this variable ?

What is the best way to set or retrieve database server variable with a JDBC Connection ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:00:25+00:00Added an answer on May 25, 2026 at 1:00 pm

    Have you tried adding it into the getConnection call?

    String url = "jdbc:mysql://localhost/test?user=sqluser&password=sqluserpw&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT'";
    Class.forName("com.mysql.jdbc.Driver");
    Connection c = DriverManager.getConnection(url);
    

    Regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I check for an open connection in jdbc for oracle database? Note:
So I have a MySQL database set up on a Debian server and it
I am opening a database connection to H2 with the following URL: jdbc:h2:../webapps/h2_db/MyDB;MODE=MySQL I
I am trying to connect to mysql database from jsp page. The connection code
I have set up Tomcat to use a connection pool yet after the MySQL
So I'm aware of some relative differences i.e., the ResultSet has an 'open connection'
I want to config tomcat server with mysql 5.1 community edition (on win server
I have a java program that connects to a MySql database and it's working
The Open/Closed Principle states that software entities (classes, modules, etc.) should be open for
I open a connection like this: Using conn as New OdbcConnection(connectionString) conn.Open() //do stuff

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.