Category Archives: MYSQL

Solution to the error of ora-06550 pls-00103 when Django connects Oracle to run PLSQL statement

Django connects Oracle and runs PLSQL statements

The code is as follows:

def exec_db():
    sql = """
    DECLARE
       v_money BINARY_INTEGER := 10;
    BEGIN
        dbms_output.put_line('Hello World');
       UPDATE TEST1 SET USER_SALERY=USER_SALERY+v_money;
       COMMIT;
    END; """
    # sql ='DECLARE v_money BINARY_INTEGER := 10; BEGIN UPDATE TEST1 SET USER_SALERY=USER_SALERY+v_money; COMMIT; END;'
    db_conn = connections['accounting']
    cursor = None
    try:
        cursor = db_conn.cursor()
        cursor.execute(sql)
        db_conn.commit()
    except:
        logger.error(traceback.format_exc())
    finally:
        if cursor:
            cursor.close()
        db_conn.close()

This SQL has no problem in the database connection tool, but the following error is reported in the code:

django.db.utils.DatabaseError: ORA-06550: line 8, column 7:

PLS-00103: Encountered the symbol “end-of-file” when expecting one of the following: ;

The symbol “;” was substituted for “end-of-file” to continue.

There are problems in writing SQL as multiple lines and single line.

Finally found the last; After that, add a space as the end. It’s going to work.

There’s no problem with one or more lines.

It’s very weird. Record it.

[Solved] Record an error of expdp export ora-01555 caused by lob damage

Error:

expdp user1/XXXXXXXX directory=szdata1 dumpfile=szhzinfo_20180319.dmp logfile=szhzinfo_20180319.log exclude=STATISTICS,INDEX tables=TKINFO QUERY=\”WHERE voteproccesstime between 20180304000000 and 20180304235959 \”

Processing object type DATABASE_EXPORT/SCHEMA/POST_SCHEMA/PROCACT_SCHEMA
ORA-31693: Table data object “USER1″.”TKINFO” failed to load/unload and is being skipped due to error:
ORA-29913: error in executing ODCIEXTTABLEPOPULATE callout
ORA-01555: snapshot too old: rollback segment number with name “” too small
ORA-22924: snapshot too old

The most immediate response to the ORA-01555 error is whether the undo tablespace size is sufficient, and whether the undo_retention parameter is set too small.

After verification, none of the above problems are caused.

Since the table has BLOB type columns, after searching MOS suspected that the BLOB is corrupted

IF: ORA-1555 Error During Export on LOB Data (Document ID 1950937.1)
LOBs and ORA-01555 troubleshooting (Document ID 846079.1)

Start troubleshooting for corrupt LOB field rows: 1.

1. create a table to store the rowid of the lob damaged rows

SQL> create tablecorrupted_lob_data(corrupt_rowid rowid, err_num number);

SQL> DESC LOBDATA

Name Null?Type
———- ——— ————
ID NOT NULL NUMBER
DOCUMENT BLOB

2. Execute the following plsql block to find the rows with corrupt lob

declare
error_1578 exception;
error_1555 exception;
error_22922 exception;
pragma exception_init(error_1578,-1578);
pragma exception_init(error_1555,-1555);
pragma exception_init(error_22922,-22922);
n number;
begin
for cursor_lob in (select rowid r, &&lob_column from &table_owner..&table_with_lob) loop
begin
n := dbms_lob.instr (cursor_lob.&&lob_column, hextoraw (‘889911’)) ;
exception
when error_1578 then
insert intocorrupted_lob_datavalues (cursor_lob.r, 1578);
commit;
when error_1555 then
insert intocorrupted_lob_datavalues (cursor_lob.r, 1555);
commit;
when error_22922 then
insert intocorrupted_lob_datavalues (cursor_lob.r, 22922);
commit;
end;
end loop;
end;
/

Enter value for lob_column: BYTE_IMAGE
Enter value for table_owner: USER1
Enter value for table_with_lob: TKINFO
old 10: for cursor_lob in (select rowid r, &&lob_column from &table_owner..&table_with_lob) loop
new 10: for cursor_lob in (select rowid r, BYTE_IMAGE from USER1.TKINFO) loop
old 12: num := dbms_lob.instr (cursor_lob.&&lob_column, hextoraw (‘889911’)) ;
new 12: num := dbms_lob.instr (cursor_lob.BYTE_IMAGE, hextoraw (‘889911’)) ;

3. query result found rowid AAAhS4AAUAAE3IRAAC row blob column is corrupted

SQL> select * from corrupt_lobs;

CORRUPT_ROWID ERR_NUM
—————— ———-
AAAhS4AAUAAE3IRAAC 1555

Modify the export statement to skip the corrupt blob rows, re-export, and export successfully

expdp user1/XXXXXXXX directory=szdata1 dumpfile=szhzinfo_20180319.dmp logfile=szhzinfo_20180319.log exclude=STATISTICS,INDEX tables=TKINFO QUERY=\”WHERE rowid NOT IN \(\’AAAhS4AAUAAE3IRAAC\’\) and voteproccesstime between 20180304000000 and 20180304235959 \”

IDEA Connect MYSQL Error: You have an error in your SQL syntax : ‘OPTION SQL_SELECT_LIMIT=1000’ (or…

 

IDEA console error message.
    check the manual that corresponds to your MySQL server version for the right
    Code: 1064, SQL State: 42000]  You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=1000''OPTION SQL_SELECT_LIMIT=DEFAULT')at line 1



Problem solving process.
    Update mysql version according to "You have an error in your SQL syntax", "your MySQL server version", to no avail.

    Check the pom.xml
        <! -- Importing Mysql database link jar package -->
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>${mysql-connector.version}</version>
                    <scope>runtime</scope>
                </dependency>

    According to "OPTION SQL_SELECT_LIMIT=1000 (DEFAULT)", the online information will be srm project, ssm (Basic-Single-Module-SSM) project to change the mysql driver file in Database to mysql-connector-java-5.1.21.jar successfully.

How to Solve MYSQL Error: Plugin ‘FEDERATED’ is disabled. /usr/sbin/mysqld: Table ‘mysql.plugin’…

After installing MySQL today, an error occurred when opening it:

1. Open the corresponding folder to view the error message:

2. Open the error information file and check that the error reason is: plug in ‘federated’ is disabled./usr/SBIN/mysqld: table ‘mysql. Plugin’ doesn’t exist

3. The reason why ‘mysql. Plugin’ does not exist is that after the newly installed MySQL service, it is generally necessary to perform database initialization operation to generate permission related tables. The execution command is as follows:

/usr/bin/mysql_install_db --user=mysql

4. If the command is executed successfully, it is best. If the following error is reported:

The solution is to install the Autoconf library

yum -y install autoconf

5. Then execute the database open command, it will succeed

service mysql start

Tip: it’s better to install the database in usr/local/because many things by default point to this folder

[java & MySql] Path does not chain with any of the trust anchors

Knowledge map advanced must read: read how large-scale map data efficient storage and retrieval>>>

When installing the application on the customer’s site, the application failed to start. The error is as follows:

 1 2018-12-12 20:17:44.371 |-ERROR [Druid-ConnectionPool-Create-116919541] com.alibaba.druid.pool.DruidDataSource [2471] -| create connection SQLException, url: jdbc:mysql://127.0.0.1:3306/xx?characterEncoding=utf8&useSSL=true, errorCode 0, state 08S01
 2 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
 3 
 4 The last packet successfully received from the server was 905 milliseconds ago.  The last packet sent successfully to the server was 899 milliseconds ago.
 5     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 6     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 7     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 8     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
 9     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
10     at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:990)
11     at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:201)
12     at com.mysql.jdbc.MysqlIO.negotiateSSLConnection(MysqlIO.java:4912)
13     at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1663)
14     at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1224)
15     at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
16     at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
17     at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
18     at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
19     at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
20     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
21     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
22     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
23     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
24     at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
25     at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
26     at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
27     at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:156)
28     at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218)
29     at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:150)
30     at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1560)
31     at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1623)
32     at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2468)
33 Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
34     at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
35     at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1959)
36     at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:328)
37     at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:322)
38     at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1614)
39     at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
40     at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1052)
41     at sun.security.ssl.Handshaker.process_record(Handshaker.java:987)
42     at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
43     at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
44     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
45     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
46     at com.mysql.jdbc.ExportControlled.transformSocketToSSLSocket(ExportControlled.java:186)
47     ... 21 common frames omitted
48 Caused by: java.security.cert.CertificateException: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
49     at com.mysql.jdbc.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:302)
50     at sun.security.ssl.AbstractTrustManagerWrapper.checkServerTrusted(SSLContextImpl.java:985)
51     at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1596)
52     ... 29 common frames omitted
53 Caused by: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
54     at sun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:153)
55     at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:79)
56     at java.security.cert.CertPathValidator.validate(CertPathValidator.java:292)
57     at com.mysql.jdbc.ExportControlled$X509TrustManagerWrapper.checkServerTrusted(ExportControlled.java:295)
58     ... 31 common frames omitted

Search on the Internet is a certificate problem, the address of usessl can be changed to false

After installing 5.7 database in windows, no error was reported

MySQL Reading table information for completion of table and column names

When you open the database, you will find that:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| backup_operation   |
| information_schema |
| operation          |
+--------------------+
3 rows in set (0.09 sec)

mysql> use operation;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

Load table and column names to complete the table information

You can turn off this feature for faster startup using option: – A

To put it bluntly, you can add a – a option to the login database without pre reading the database information

The following reasons are found on the Internet:

The reason for the problem is::
       We entered mysql without using the -A parameter.
       That is, we use
           mysql -hhostname -uusername -ppassword -Pport to access the data, the
       instead of using
           mysql -hhostname -uusername -ppassword -Pport -A to access the database.
 
           When we open the database, i.e., use dbname, we have to pre-read the database information, and when we use the -A parameter, we do not pre-read the database information.
 
The key factor is that your database gets bigger. The system becomes slower

There is another case:

When accessing the database today:

Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Generally, this problem occurs because the database in MySQL is too large, resulting in too long read ahead time, thus displaying this prompt. If this problem has not been encountered before, then the cause of this problem may be due to the operation of changing database information, such as dropping a large table (tens of millions of data) and terminating halfway

First, check the current process

mysql> show processlist ;

If the ID of the lock table in the figure above is 16545618, you can use the kill command to end it

mysql> kill 16545618;

If I delete these lock tables, my MySQL will be able to access them normally

 

mysql Remote connection problems: Lost connection to MySQL server at ‘reading initial communication packet’, syste…

When using Navicat for MySQL to remotely connect to MySQL, there is a problem

Lost connection to MySQL server at ‘reading initial communication packet’, system error: 0

It’s disgusting. The server was rebooted once, and it was dealing with all kinds of MySQL problems all morning

Two methods were tried, but they didn’t work

Modify my.cnf file (my.ini for Windows)

Generally, it is in the installation directory of MySQL,/etc/mycnf

Add skip name resolve in the [mysqld] zone of my.cnf configuration file. What netizens say is to skip the DNS reverse resolution function of MySQL connection, which can improve the performance of MySQL. In this case, you can only use the IP in the MySQL authorization table to connect to the MySQL service

But it doesn’t work. Several parameters of my.cnf configuration are attached:
skip name resolve skips the DNS reverse resolution process. (in this way, you can’t use the host name to connect to MySQL, you can only use the IP connection)
skip grant tables skips the authorization table (the solution when the MySQL login password is forgotten)
skip networking skips the TCP/IP connection
skip host cache disable the host name cache; To clear the host name cache, execute the flush hosts statement or the mysqladmin flush hosts command

write the IP address of the client in the/etc/hosts file of the MySQL server, and do the host mapping for any name

Because the working environment needs to access MySQL at multiple addresses, it is unrealistic to maintain the hosts file all the time, so it is eliminated

It turns out that
remote access to MySQL is OK, but not local access, which means that you can run in the production environment as usual. It’s disgusting

Solving the problem of QT connecting MySQL database in Windows system: qmmysql driver not loaded

In the process of learning QT, we encountered the situation that we could not connect to the database

#include <QApplication>
#include <QtSql>
#include <QMessageBox>
#include <QDebug>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

 //Show existing database driver
    qDebug()<<QSqlDatabase::drivers();

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("localhost");
    db.setDatabaseName("dbname");
    db.setUserName("root");
    db.setPassword("password");
    
    if (!db.open()) {
       QMessageBox::critical(0, QObject::tr("Database Error"),
                              db.lastError().text());
    }

    return a.exec();
}

The output of the console is:

As shown above, MySQL driver exists, but it still prompts an error: qmmysql driver not loaded

The reason is that libmysql.dll is missing in the program

This dynamic connection library is in the Lib directory of the MySQL installation file. For example, if my MySQL is installed on Disk C, libmysql.dll is located at:

C:\MySQL\MySQL Server 5.7\lib\

Find libmysql.dll, copy it to the directory where your exe is located, and then run the program. At this time, you can connect to MySQL

note: 32-bit QT program must use 32-bit libmysql.dll, not 64 bit. Similarly, 64 bit programs use 64 bit libmysql. DLL

Libmysql.dll can be found in the Lib directory of the MySQL installation file

If there is no corresponding version, you can also download it here:

Connection: http://pan.baidu.com/s/1kVKwLuR

Password: v6uy

You can connect to the database through the above method, but it is very troublesome to copy libmysql.dll to the directory where the EXE is located every time. Therefore, when writing programs, you can use a convenient method:

Copy libmysql.dll to the bin directory of QT installation file, such as my bin directory:

D:\Qt\Qt5.7.0\5.7\mingw53_32\bin\

After copying to the bin directory, there is no need to copy libmysql.dll to the directory where the EXE is located. The program can connect to the MySQL database correctly

[How to Solve] psql: FATAL: role “postgres” does not exist

I’m a postgres novice.

I installed the postgres.app for mac. I was playing around with the psql commands and I accidentally dropped the postgres database. I don’t know what was in it.

I’m currently working on a tutorial:http://www.XXX.com/blog/building-a-project-with-mezzanine/

And I’m stuck atsudo -u postgres psql postgres

ERROR MESSAGE:psql: FATAL: role "postgres" does not exist

$ which psql

/Applications/Postgres.app/Contents/MacOS/bin/psql

This is what prints out ofpsql -l

                                List of databases
    Name    |   Owner    | Encoding | Collate | Ctype |     Access privileges     
------------+------------+----------+---------+-------+---------------------------
 user       | user       | UTF8     | en_US   | en_US | 
 template0  | user       | UTF8     | en_US   | en_US | =c/user                  +
            |            |          |         |       | user      =CTc/user      
 template1  | user       | UTF8     | en_US   | en_US | =c/user                  +
            |            |          |         |       | user      =CTc/user      
(3 rows)

So what are the steps I should take?Delete an everything related to psql and reinstall everything?

Thanks for the help guys!

 

linux

Note that the error message doesNOTtalk about a missing database, it talks about a missing role. Later in the login process it might also stumble over the missing database.

But the first step is to check the missing role: What is the output withinpsqlof the command\du?On my Ubuntu system the relevant line looks like this:

                              List of roles
 Role name |            Attributes             | Member of 
-----------+-----------------------------------+-----------
 postgres  | Superuser, Create role, Create DB | {}        

If there is not at least one role withsuperuser, then you have a problem 🙂

If there is one, you can use that to login. And looking at the output of your\lcommand: The permissions foruseron thetemplate0andtemplate1databases are the same as on my Ubuntu system for the superuserpostgres. So I think your setup simple usesuseras the superuser. So you could try this command to login:

sudo -u user psql user

Ifuseris really the DB superuser you can create another DB superuser and a private, empty database for him:

CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;

But since your postgres.app setup does not seem to do this, you also should not. Simple adapt the tutorial.

 

window

/Applications/Postgres.app/Contents/Versions/9.*/bin/createuser -s postgres