Tag Archives: The database

E: unable to locate package MySQL server error solution

In Ubuntu system, using the apt-get install command to install the program, the following problems occurred.

[email protected]:~# sudo apt-get install mysql-server -y
sudo: unable to resolve host iZm5ej8y1b74lo14r36fvlZ
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package mysql-server

Solutions:
Sudo apt-get update sudo apt-get update
The software source is not updated, or the software source is modified,

sudo apt-get update

Second method: need to change the software source
Refer to the method of replacing the software source:

http://www.chenxm.cc/post/445.html

E: Unable to locate package mysql-server: Unable to locate package mysql-server: Unable to locate package mysql-server

Can’t open file: (errno: 24)

New structures, the database, the application after connecting up, with the following process:
120528 10:07:32 [ERROR]/usr/local/mysql/bin/mysqld: Can ‘t open file:./ag4_1/raa4_1 FRM’ (24) errno:
I didn’t look at the error code carefully at first! Thought the file was corrupted, reimport! Throw the above error again!
Use the perl error tool to see specific errors!
Linux:/usr/local/mysql/bin #./perror 24
OS error code 24: Too many open files
beyond the maximum number of open file limit! The maximum number of open files on the system is 65535. It cannot be exceeded! The maximum number of open files in the database must be out of limit!
Show variables like ‘open_files_limit’; show variables like ‘open_files_limit’;
>

Reproduced in: https://blog.51cto.com/imysqldba/883374

JSON data format net.sf.json .JSONException: A JSONObject text must begin with ‘{‘ at character 1 of Error:(f…

The substring (3) the use of the http://www.w3school.com.cn/jsref/jsref_substring.asp

Possibility 1: if sb is the data to be converted, let’s say sb is a String

 


The char
The STR [] = sb. ToString (). ToCharArray ();


for
(
The int
i=
0
; i< str.length; i++){


System.out.println(str[i]);


}

After can get into an array of form, check the array before any Spaces, such as if useful
sb.toString().trim().substring(
1
); Cut off


The String json = sb. ToString (). The trim (). The substring (
1
);


The // String json = "{\" success \ ": true, \" MSG \ ": \ \" successful "} ";


System.out.println(json);


System.out.println(json.length());


The JSONObject JSONObject = JSONObject. FromObject (json. The trim ());


System.out.println(jsonobject);



The

"Result" : [{}] ------ left less {

Possibility 2: No initialization, no initBmob () is likely to report this wrong Unregistered

Possibility 3: There is an extra space before the data in the database

 

Reproduced in: https://www.cnblogs.com/wth21-1314/p/7381575.html

[Jackson exception] com.fasterxml.jackson . databind.JsonMappingException Exception handling method

In the project, the parent layer is Car.java [Vehicle Entity] and the child layer is CarCommonParam.java [Vehicle Basic Entity], which is the basic information of a vehicle to multiple vehicles
But at the time of query library collection is a entity error: 【 com. Fasterxml. Jackson. Databind. JsonMappingException 】

com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: cn.skyable.zulin.common.bean.CarCommonParam_$$_jvst95e_39["handler"])
X-Zc-Ack-->null
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:59)
	at com.fasterxml.jackson.databind.ser.impl.UnknownSerializer.serialize(UnknownSerializer.java:26)
	at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:541)
	at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:644)
	at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
	at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
	at com.fasterxml.jackson.databind.ObjectMapper.writeValue(ObjectMapper.java:1837)
	at com.fasterxml.jackson.core.base.GeneratorBase.writeObject(GeneratorBase.java:261)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalArray(ACObjectMarshaller.java:53)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshalObject(ACObjectMarshaller.java:37)
	at com.ablecloud.cloudservice.ACObjectMarshaller.marshal(ACObjectMarshaller.java:22)
	at com.ablecloud.common.ACObject.toString(ACObject.java:415)
	at java.lang.String.valueOf(String.java:2994)
	at java.lang.StringBuilder.append(StringBuilder.java:131)
	at cn.skyable.zulin.BaseTest.dealResp(BaseTest.java:88)
	at cn.skyable.zulin.logistics.TestLogistics.TestlistCarsByLogId(TestLogistics.java:65)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:539)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:761)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:461)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:207)

Error description: A truncation is made in the entity where the child layer can look up information about the parent layer, but the parent layer cannot look up information about the child layer due to circular reference problem.
Solution:
Add to the parent car.java
Instead of

Just !!!!

Invalid username / password; login denied

The following error message was sent when connecting to the database

16:10:47.547 [Druid-ConnectionPool-Create-574835454] ERROR c.alibaba.druid.pool.DruidDataSource - create connection SQLException, url: jdbc:oracle:thin:@192.168.1.2:1521:orcl, errorCode 1017, state 72000
java.sql.SQLException: ORA-01017: invalid username/password; logon denied
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:675) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:448) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:383) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:776) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:432) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) ~[ojdbc-6.jar:11.2.0.3.0]
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528) ~[ojdbc-6.jar:11.2.0.3.0]
    at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:149) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.FilterAdapter.connection_connect(FilterAdapter.java:786) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1515) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1578) ~[druid-1.1.9.jar:1.1.9]
    at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2466) ~[druid-1.1.9.jar:1.1.9]

The solution is as follows:
${username}code>${username}
${username}
${username} ${username} ${username} ${username} Or you can use the following system-properties-modeoperty when referring to the configuration file

<context:property-placeholder location="classpath:jdbc.properties" system-properties-mode="FALLBACK" />

Solution of invalid username / password; login denied error in Oracle Database Foundation

A invalid username/password; CMD must be run as administrator in win7 or win8

1. Enter command under DOS:
SQLPLUS SYS/Password set at installation as SYSDBA
(enter)

2. Then type the command:
alter user scott account unlock;
 

When you enter, the words “User has changed” will appear, and you can move on to the next step.  

3. Enter the command:
conn scott/tiger
 

After entering, an error message (as follows) will appear:

ERROR:
ORA-28001: The password has expired
 

Change Scott’s password

New password:

4. Enter a new password;  

5. Repeat the new password.  

Finally, there you go!

Reproduced in: https://www.cnblogs.com/dfyg-xiaoxiao/p/7213772.html

Solution to the problem that SQL database query result field contains new line character, which leads to copy to excel dislocation

Problem description:
in the process of work, sometimes encountered such a problem, write a SQL query to query data in the database, see the number of rows (such as 1000 rows), but make a copy of the query results to Excel, but happened mismatch, and lead to Excel in the number of lines is more than 1000 lines, caused the number of rows of data inconsistency.

field value contains char(10) newline character, copy the field value to Excel.
Source:
some corresponding cell contains a newline, lead to dislocation happened in copy to Excel.

Option 1 (Recommended) : Enclose the field values in question in double quotation marks so that the newline characters in the field values are restricted to the correct Excel cell.
scenario 2: use the script to remove the corresponding field value newline character.
create table #t
(
Name nvarchar(50),
Remark nvarchar(50)
)

insert into #t
lues (‘ A1 ‘+ char(10) +’ B1 ‘, ‘row 1’), (‘ A2B2 ‘, ‘row 2’)

select Name, Remark
om #t
— Solution 1: You can put double quotation marks directly in the field, and copy it to Excel without misplacing or showing redundant double quotation marks.
select ‘”‘ + Name + ‘”‘ as Name, Remark
om #t

select replace(replace(Name, char(13), ‘ ‘), char(10), ‘ ‘) as Name, Remark
om #t
drop table #t

Enum type and set type of MySQL

Enumeration type and collection type of MySQL
CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE

create table consumer(
    id int,
    name char(16),
    sex enum('male','female','other'),
    level enum('vip1','vip2','vip3'),
    hobbies set('play','music','read','run')
)

Enumeration here means that you can select only one from here, and set means that you can select more than one from set.
Input insert statement

insert into consumer values(1,'egon','male','vip2','music,read')

And you might be wondering, what happens if I put multiple entries in the corresponding enum?

insert into consumer values(2,'eg','male','vip1,vip2','music,read')


ah

Insert into / delete / update / select of SQL Server database table

Score
Id = int, primary key, StuName Subject Result

2>r> 3
5
.> … … …
Add a score: Name StuName is Lei Wang, Subject is Java programming, Result is 92
Insert into score(StuName,Subject,Result) Values(‘ StuName ‘, ‘Java programming’,92);
2. Delete the score information of Chinese subject
Delete from score where subject = ‘Chinese’;
Change student’s StuName to 76
Update Score Set Result= 76 Where Stuname = ‘Stuname’
Select * from user where Score> 80
Select * From Score Where Result > = 80;

@Autowired injection * * required a single bean, but 2 were found**

why
The StringRedistemplate object is injected into the project as follows:

@Autowired
private StringRedisTemplate redisTemplate;

Then it says an error:

Field redisTemplate in com.xxx.api.controller.XxxController required a single bean, but 2 were found:
  - getRedisTemplate: defined by method 'getRedisTemplate' in class path resource [com/xxx/config/RedisConfig.class]
  - stringRedisTemplate: defined by method 'stringRedisTemplate' in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConfiguration.class]

@Autowired is either injected by type or declared @Qualifier(” beanID “), which has nothing to do with the field name I defined as redisTemplate. Other
but the project is so written, nor the @ the Qualifier is not an error (and I didn’t complain before use), the only difference is the field name is different, other places are stringRedisTemplate, I changed, really good. This is clearly a metaphysical operation, if you follow the previous interpretation of @Autowired.
why

@Autowired annotation injection rule:

after some code tests, the Autowired default by Type, if the same Type to find multiple beans, then, and according to the Name way comparison, if there are more than one, then an exception is reported.

According to the error prompt: StringRedisTemplate this type of bean in container pool has two redisTemplate, StringRedisTemplate (our own projects, configured with a spring boot automatically configure also give I added a)
I defined the field name is redisTemplate: no, just the StringRedisTemplate is some, so there is no problem!
To solve
There are many solutions:

    field is modified for StringRedistemPlate to specify the injected bean using @Qualifier. In some cases, add @primary [not recommended]
the conflicting bean
END
I had memorized the infusion process deeply until I came across it. Some items in the notes didn’t impress me as being important, and I kept a summary in mind, yet I couldn’t discover its significance until I encountered the problem.