Author Archives: Robins

Leetcode-234: palindrome linked list

Topic describes
Determine whether a linked list is a palindrome list.
// 1 2 nil
// 1 2 1 nil
// 1 2 2 1 nil
Thought analysis
The fast and slow pointer finds the midpoint of the linked list and splits the midpoint and reverses the tail list to compare whether the values of the head and tail list are equal in turn
Code implementation

func isPalindrome(head *ListNode) bool {
	if head == nil {
		return true
	}
	fast := head.Next
	slow := head
	for fast != nil && fast.Next != nil {
		fast = fast.Next.Next
		slow = slow.Next
	}

	tail := reverse(slow.Next)
	slow.Next = nil

	for head != nil && tail != nil {
		if head.Val != tail.Val {
			return false
		}
		head = head.Next
		tail = tail.Next
	}
	return true
}

func reverse(head *ListNode) *ListNode {
	if head == nil {
		return head
	}
	var pre *ListNode
	for head != nil {
		temp := head.Next
		head.Next = pre
		pre = head
		head = temp
	}
	return pre
}

Export and import method of MySQL under Linux

Mysql export
Several Methods of Database

 

Methods a

Mysql> mysqldump — opt-h192.168.0.156-uusername-ppassword –skip-lock-tables databasename> The database. SQL

Change the IP address to localhost and you can use www.2cto.com

If Navicate is installed, then it is even easier to connect to the database, select the database, and then dump the SQL

Method 2

Enter CMD (note in OS CMD and not in MySQL)

= = = = = = = = = = = = = = = = = = =

1. Export database (SQL script)

Mysqldump -u username -p database name> Export filename

mysqldump -u root -p db_name > test_db.sql

Mysql> export a table from mysql

Mysql> mysqldump -u -p; Export filename

mysqldump -u wcnc -p test_db users> Test_users.sql (no semicolon at the end)

Methods three

Mysql> start mysql

/etc/init.d/mysql start

Export the entire database

mysqldump dbname > C: mydb. SQL -u root -p

Import the database

source mydb.sql

Mysql -u username -p database name < Database name.sql

More detailed database import tutorial

www.2cto.com

2.1. Export SQL Scripts

From the original database server, you can export SQL scripts using the PHP tutorial myadmin tool or the mysqldump command line (mysqldump command is located in the mysql/bin/ directory).

2.1.1 Use the phpMyAdmin tool

In the export options, select export “structure” and “data” and do not add “drop database” and “drop table” options.

Select the “save as file” option, or if you have a lot of data, select the “gzipped” option.

Save the exported SQL file.

2.1.2 Use the mysqldump command line

The command format

Mysqldump -u username -p database name> Database name.sql

Example:

mysqldump -uroot -p abc > abc.sql

Export database ABC to ABC. SQL file

When prompted for a password, enter the password for the user name of the database.

2.2. Create an empty database

From the master interface/control panel, create a database. Assume that the database name is ABC and the database full user is ABC_F.

2.3. Import SQL script for execution

There are also two methods, one using phpMyAdmin (my)
SQL database management tools, or
MySQL command line.

2.3.1 Use the phpMyAdmin tool

From the control panel, select the empty database to create, and click “Manage” to go to the admin tools page.

In the “SQL” menu, browse and select the exported SQL file, and click “Execute” to upload and execute.

Note: phpMyAdmin has a limit on the size of uploaded files, and PHP itself has a limit on the size of uploaded files, if the original SQL file is used

It is relatively large, you can use gzip to compress it first, for text files such as SQL files, you can get 1:5 or more compression ratio.

How to use gzip: www.2cto.com

# gzip xxxxx.sql

get

XXXXX. SQL. Gz file.

2.3.2 Use the MySQL command line

The command format

Mysql -u username -p database name < Database name.sql

Example:

mysql -uabc_f -p abc < abc.sql

Import database ABC from ABC. SQL file

When prompted for a password, enter the password for the user name of the database.

Usually, you may use a lot of MySQL import and export methods, today I will introduce you several import and export MySQL data methods, convenient for you to use in work.
Here’s what Baidu got:

Mysql> import files or data or execute related SQL

    1

    Mysql -h host address -u user name -p user password mysql -h host address -u user name -p user password (shell command line)
    mysql -u root -p dbname < filename.sql

    2

    Execute an SQL
    directly on the command line (shell command line)
    mysql -hhostname -uusername -p dbname -e ‘select * from tbname limit 1’
    After execution, the command line will prompt for the database password.

    3

    echo ‘select id from dbname.tbname where id = 1; ‘ | mysql -hhostname -ureadonly -preadonly dbname > xxxx.sql

    4

    Enter the MySQL database (where the SQL file is executed)
    > source xxx.sql

    END

Mysqldump = mysqldump;

    1

    Mysqldump -u user name -p password -h host database a-w “SQL condition” — lock-all-tables>; Path
    mysqldump -hhostname -uusername -p dbname tbname> xxxx.sql

    2

    ** Export the contents of the database table on the specified criteria. (-w option — where)
    mysqldump -hhostname -uusername-p dbname tbname -w’id > = 1 and id< = 10000′–skip-lock-tables > xxxx.sql

    3

    Or the next line is
    mysqldump -hhostname -uusername -p dbname tbname –where=’unit_id > = 1 and unit_id < = 10000′> ~/xxxx.sql

    END

Mysqldump Export Database Table

    1

    mysqldump -u username -p database name> Export file name
    > mysqldump -u breezelark-p mydb > mydb.sql

    2

    mysqldump -u username -p database name>
    mysqldump -u username -p database name> Export file name
    mysqldump -u lingxi -p mydb mytb> mytb.sql

    3

    Export a database structure (no data only structure)
    mysqldump -u lingxi -p -d –add-drop-table mydb > mydb.sql
    – d no data – add – drop – table before each the create statement adds a drop table
    of course this is just one way of import and export, you can feel the choice suits own method.

Import / export. SQL file / gzip file for MySQL under Linux

    ready. SQL file and upload to server login server MySQL import. SQL file
If you need to create the database for the entire database file you don’t need to create the database for the table file
Source *.sql //.sql file path
 
3. Export. SQL file
Export table structure
It’s going to be in the data directory
cd /mysql/data/
. /bin/mysqldump -uroot -p -d newdb > Newdb.sql // newdb database name
// Enter the password
 
Export data and table structures
It’s going to be in the data directory
cd /mysql/bin/
. /bin/mysqldump -uroot -p newdb > Newdb.sql // newdb database name
// Enter the password
 

    exports the gzip file
It’s going to be in the data directory
. /bin/mysqldump -uroot -p –default-character-set=utf8 xw_taes | gzip > /home/xw_taes_1.sql.gz
// Enter the password
 

    import gzip
In any directory
gzip -d < /home/xw_taes_1.sql.gz | mysql -uroot -p xw_taes_1
// Enter the password
Xw_taes_1 is the name of the database to import
There is no meeting

 
Note: Adding plaintext password directly will report an error

cvc-complex-type.2.3: Element ‘beans’ cannot have character [children]

When writing Spring’s ApplicationContext.xml file, out of nowhere:
CVC-Complex Type.2.3: Element ‘beans’ cannot have character [children], because the type’s content type is element-only. Error.

Error: Spring does not recognize the elements in ApplicationContext.xml when initialized.
Possible reasons for this error: The code copied online is pasted directly into an XML file, and the code on the Web may not conform to the XML specification

Remove the Chinese annotations from the XML file, because some of the annotations copied are not recognized by Spring.  
2. If there is still an error, try to modify the extra space, because Chinese space Spring may recognize the error.
3. Last resort: Copy the file again manually and save it.

Problems of accessing servlet display 404 on MyEclipse

Sometimes, when accessing a servlet in MyEclipse, a 404 page will appear. I won’t go into this if the web.xml is not configured properly or the URL is wrong, but I will talk about the situation where everything seems to be correct but I still can’t access it.
All you need to do is find the container where the servlet is running, in this case Tomcat, close it first, then locate the corresponding project in Tomcat, click ReDeploy, and then start Tomcat.

Possible causes and solutions of 404 problems in accessing servlet pages

Today I finished a function Want to direct input in the address bar servletA class and parameters to test the servlet code
an error 404. But I tested a new servletB class and it worked exactly the same way.
I was puzzled because both classes were servlets I created directly from Eclipse, and the web.xml was configured automatically. Even if the configuration is wrong it should be both wrong. Want to for a long time, suddenly think of you just created ServletA class, put the wrong to service pack, dragged her into the servlet found directly after the bag, but the web. The XML configuration path has been in the service package
as shown in figure
and the actual class names should be com. Student. Servlet. DeleteStudentServlet
for simple reason is:
I just begin to create the servlet misplacing to service the bag (actually should put the servlet bag), but to create the eclipse will help me get web. The XML class name is automatically configured (the name of the class is the route of the distribution of com. Student. Service. DeleteStudentServlet) and I treat the servlet to tow the servlet packages, web, XML is not modified, lead to the web. The path name of the class error in the XML. So when he visited the Servlet can’t find the correct path, to be an error 404.
so the Servlet error 404, must be sure to check the path name is correct, also want to check the web, XML configuration information is incorrect.
Summary: Make sure to go to web.xml to change the configuration if the package you created the Servlet contains changes.

Exception of browser accessing servlet404

* *
Error about creating a servlet when viewed in a browser
**

user initiates a request, which is received by the server, and finds out if the requested resource exists according to the configuration information in the web.xml file. If it does not exist, a 404 error is returned.
After the resource is found (the servlet is found), the servlet object is checked to see if it exists, if not, the object is created, and if it does, the corresponding processing method is executed.
After the execution of the processing method, the processing result will be returned to the Web server. After the Web server carries out relevant processing according to the result, it will be returned to the browser, and the browser will display the corresponding processing result.
————————————————
lution for link
Reasons for appearing:
In 404 because the
in the create project is not changed when buildpath WebContent/WEB – INF/classes
cause no class file
so error
Second, if there is no @WebServlet(“/test”) link, you should configure the web.xml file
in the WebContent/ web-inf directory

<servlet>
    <servlet-name>xxx</servlet-name>
    <servlet-class>day2ByServlet.Servlet$One</servlet-class>
    <init-param>
      <param-name>p</param-name>
      <param-value>xixi</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>xxx</servlet-name>
    <url-pattern>/Servlet$One</url-pattern>
  </servlet-mapping>
  <servlet>
    <servlet-name>yyy</servlet-name>
    <servlet-class>day2ByServlet.HttpServlet_two</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>yyy</servlet-name>
    <url-pattern>/ServletTwo</url-pattern>
  </servlet-mapping>

404 error in browser accessing Servlet

The first Servlet program written with the MyEclipse tool — HelloWorld (refer to Section 4.1 of Java Web Programming). After the Web project is created, Tomcat is started through the MyEclipse development tool. See the Console window to output the server startup information as follows:

Then, when testing the program by typing the URL in the browser address bar, a 404 error occurs, as shown below:

My development environment is MyEclipse 2014+Tomcat 8.0. Previously, there were some new features in MyEclipse that did not support JDK 1.8. Later, I wondered if there was a version mismatch between development environments, so I tried to change Tomcat 8.0 to Tomcat 7.0.

How to convert iconfont to PNG transparent image

1. Enter the IconFont icon library and log in. http://www.iconfont.cn/
2. Select the desired icon and add it to the shopping cart.
3. Select the download icon as PNG format.
https://blog.csdn.net/weixin_30788619/article/details/95338105
Selected state: download after changing the color, and then rename all activated items to complete the matching effect