Derby password setting tutorial

Source: Internet
Author: User
Tags builtin

Method 1: configure the Derby. propertites file:

File Content:

Derby. Connection. requireauthentication = true
Derby. Authentication. provider = builtin
Derby. User. Username = Password

Change username and password to what you need. Set username to sa first (there will be a problem here, I will talk about it later) and password to Password

Put this file in the directory where your database is located.

Open cmd, enter the database directory, and run the IJ tool. If you do not enter the user name and password, just enter the following statement:

Connect 'jdbc: Derby: testdatatype; Create = true ';

IJ will prompt you 'Connection authentication failure occurred. Reason: invalid authentication ..'

Therefore, run the following statement:

Connect 'jdbc: Derby: testdatatype; Create = true; user = sa; Password = password ';

Next, if you want to operate the database, there may be problems. Try to select some data, oops!


The database mode named 'sa 'does not exist. Derby uses the same mode as the user name by default after a user logs on. If this mode does not exist, an error is returned. There are two ways to solve this problem:
First, let's take a look at the name of your database's existing model? If my account is an app, create a user named app and log on to the app database to perform operations directly.

 

Second, log on directly with SA without changing the user name. After logging on, run this statement: Set schema app; then the operation is OK. No picture, no truth, see the picture:

Don't be so happy. Let's run to another path and execute IJ. The miserable thing is coming soon:

Check that I am running IJ in the root directory of the C drive. I can directly query the database without the user name or password.

What should we do?

The second method is to set the Derby Database Password.

Method 2: set a password for a database.

The configuration Derby. properties file is used to configure system settings for the Derby database. That is, if other databases exist in the Database directory, they will also use the username and password set by Derby. properties to log on. If. run IJ, Derby. properties will no longer take effect. IJ will use the default embed mode configuration of Derby, that is, the database can be queried without the user name and password.

This is not what I want (why is it designed like this? I am puzzled. If this is the case, you only need to know the path of your database and use IJ in other paths to change your database ). I hope that the user name and password I set must be used to query the database no matter where I run IJ.

Use IJ to connect to the database and run the following statement:

Call syscs_util.syscs_set_database_property ('derby. Authentication. provider ',
'Builtin ');
Call syscs_util.syscs_set_database_property ('derby. Connection. requireauthentication ',
'True ');
Call syscs_util.syscs_set_database_property ('derby. User. username ',
'Password'); ---- change the username and password here to yours. Enter the settings here next time you log on.
Call syscs_util.syscs_set_database_property ('derby. database. fullaccessusers ',
'Username'); ---- This username is the same as the previous one.
Call syscs_util.syscs_set_database_property ('derby. database. defaultconnectionmode ',
'Noaccess ');

Exit ij and run:

If you do not enter the user name or password, you cannot access the service. Enter the following information:

Success! No matter where you put the database or where you run IJ, you must use the user name and password to query it.

If you need a password: run the above statement and change the password to a new one. When you run the database again, you will be asked to enter the new password.

Delete the password, that is, change it back without using the user name and password to log on:
Only run this sentence:

Call syscs_util.syscs_set_database_property ('derby. Connection. requireauthentication ',
'False ');

All operations can be completed using the IJ tool in cmd. In this way, you do not need to use the Derby. propertites file. However, the user name and password must be kept in mind.

From: http://www.joyzhong.com/archives/643

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.