Tag Archives: data

Method of adding operation button for each line of data in DataGrid of easyUI

When I was working on the project today, I wanted to add an operation button after each column of data in the DataGrid of easyUI. At the beginning, I wanted to splice strings in the background and return them with JSON. But after testing, I found that this method didn’t work. I searched the Internet and sorted them out as follows:

In fact, it’s very easy to add a row of custom columns. When JS declares DataGrid, add the following code

<span style="font-size:18px;">{field:'operate',title:'act',align:'center',width:$(this).width()*0.1,
	formatter:function(value, row, index){
		var str = '<a href="#" name="opera" class="easyui-linkbutton" ></a>';
		return str;
}}</span>

This line of code is defined under the columns property, and it must be added

<span style="font-size:18px;">onLoadSuccess:function(data){  
        $("a[name='opera']").linkbutton({text:'buy',plain:true,iconCls:'icon-add'});  
},</span>

If you don’t add this, there will be no button style in that operation column. It’s just a hyperlink. You can use LinkButton or other buttons according to your needs

 

 

Python uses CX_ Oracle batch insert error report ora-01036 error solution

Recently, in the process of using Python to write data import program, CX is used_ When the Oracle database was imported into Oracle database, there was an error of “ora-01036: illegal variable name/number”. After querying the data and trying, the problem was solved.

The Error statement is:

sql = ‘insert into \”mytable_ a\” values(%s,%s,%s)’

cursor.executemany (sql, data)

As a result, the error “ora-01036: illegal variable name/number” appears.

resolvent:

Change the place holder of parameter transfer to “: 1,: 2,: 3”,

The modified statement is as follows:

sql = ‘insert into \”mytable_ a\” values(:1, :2, :3)’

cursor.executemany (sql, data)

Execute again and solve the problem.

Oracle data file space release

When the data of Oracle database takes up a large space, and the data stored in it does not take up such a large space, the reason may be that the user has deleted some data, but the size of the data file will not automatically shrink. At this time, if you want to reduce the size of the data file, you can use the following methods.

1、 Use the following statement to query data files that can free up space:

select a.file#,

a.name,

a.bytes/1024/1024 CurrentMB,

ceil(HWM * a.block_ size)/1024/1024 ResizeTo,

(a.bytes – HWM * a.block_ size)/1024/1024 ReleaseMB,

‘alter database datafile ”’ || a.name || ”’ resize ‘ ||

ceil(HWM * a.block_ size)/1024/1024 || ‘M;’ ResizeCmd

from v$datafile a,

(SELECT file_ id, MAX(block_ id + blocks – 1) HWM

FROM DBA_ EXTENTS

GROUP BY file_ id) b

where a.file# = b.file_ id(+)

And (a.bytes – HWM * a.block_ size) >0

and rownum < 10

View the data file that belongs to the system table space, and reset it.

2、 Find out the data file that needs to be reset, and execute the reset statement

An error is reported because the reset data file size needs to be set to an integer.

Adjust the size of resize to 16GB, 16384mb;

3、 View free disk space

The size of the system file is reduced to 16GB, the remaining space of the root disk is greatly increased to 19.6gb, and the utilization rate is reduced to 78%.

Local refresh of listview and GridView

As we all know, listview and GridView refresh the interface by calling adapter.notifyDataSetChanged () refresh the interface. But this method has its disadvantages. It refreshes all the data in the interface, no matter whether the data has changed or not. If listview loads a lot of data (e.g. 100 entries)

When refreshing, it will cause a lot of system overhead. How to refresh only one like QQ space personal dynamic

Main principles:
refresh an item in listview
1. Get the current index position and data of the item to be refreshed
2. Reset the acquired data
3. Put the reset data in the original position of the data set in the adapter (refresh a piece of data in the original data set according to the position)
4. Get the view of the sub item to be refreshed in listview
5. Get new data from the updated data set and update the data in viwe (operate in handler to refresh the interface)

The functions are as follows, with detailed comments in the code:

public class MainActivity extends Activity  
{  

    private ArrayList<MyListItem> list = null;  
    private ListView              lv;  
    private MyListAdapter         adapter;  

    @Override  
    protected void onCreate(Bundle savedInstanceState)  
    {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.activity_main);  
        intitData();  
        lv = (ListView) findViewById(R.id.listView1);  
        adapter = new MyListAdapter(list, getApplicationContext());  
        adapter.setListView(lv);  
        lv.setAdapter(adapter);  

        lv.setOnItemClickListener(new OnItemClickListener()  
        {  

            @Override  
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)  
            {  
                // Get the data of the clicked item in the listview   
                MyListItem item = (MyListItem) parent.getItemAtPosition(position);  
                Log.i("eee", item.getData() + " == " + item.getPosition());  
                // Update data  
                item.setData("update item " + position);  
                // Update Interface  
                adapter.updateItemData(item);  
            }  
        });  

    }  

    /** 
     * Initialization data 
     */  
    private void intitData()  
    {  
        list = new ArrayList<MyListItem>();  
        for (int i = 0; i < 20; i++)  
        {  
            MyListItem item = new MyListItem();  
            item.setData("item " + i);  
            item.setPosition(i);  
            list.add(item);  
        }  
    }  

    /** 
     * Customize item data type 
     */  
    class MyListItem  
    {  
        /** 
         * data id 
         */  
        private int    dataId;  
        /** 
         * datas 
         */  
        private String data;  

        public int getPosition()  
        {  
            return dataId;  
        }  

        public void setPosition(int position)  
        {  
            this.dataId = position;  
        }  

        public String getData()  
        {  
            return data;  
        }  

        public void setData(String data)  
        {  
            this.data = data;  
        }  

    }  
}  
activity to call, the function operation is mainly encapsulated in the adapter as follows.

public class MyListAdapter extends BaseAdapter  
{  

    /** 
     * Data sets in listview 
     */  
    private ArrayList<MyListItem> mDataList;  

    private Context               mContext;  
    private ListView              mListView;  

    public MyListAdapter(ArrayList<MyListItem> list, Context cont)  
    {  
        this.mDataList = list;  
        this.mContext = cont;  
    }  

    /** 
     * Set the listview object 
     *  
     * @param lisv 
     */  
    public void setListView(ListView lisv)  
    {  
        this.mListView = lisv;  
    }  

    /** 
     * update listview Single data 
     *  
     * @param item New data object 
     */  
    public void updateItemData(MyListItem item)  
    {  
        Message msg = Message.obtain();  
        int ids = -1;  
        // Compare data to get the position of the corresponding data in the list  
        for (int i = 0; i < mDataList.size(); i++)  
        {  
            if (mDataList.get(i).getPosition() == item.getPosition())  
            {  
                ids = i;  
            }  
        }  
        msg.arg1 = ids;  
        // Update the data in the corresponding position of mDataList  
        mDataList.set(ids, item);  
        // handle refreshes the interface  
        han.sendMessage(msg);  
    }  

    @SuppressLint("HandlerLeak")  
    private Handler han = new Handler()  
                        {  
                            public void handleMessage(android.os.Message msg)  
                            {  
                                updateItem(msg.arg1);  
                            };  
                        };  

    /** 
     * Refresh the specified item 
     *  
     * @param index item's position in listview 
     */  
    private void updateItem(int index)  
    {  
        if (mListView == null)  
        {  
            return;  
        }  

        // Get the currently visible position of the item  
        int visiblePosition = mListView.getFirstVisiblePosition();  
        // If you add headerview, firstview is hearderview  
        // All indexes + 1 to get the first view  
        // View view = listview.getChildAt(index - visiblePosition + 1);  
        // Get the clicked view  
        View view = mListView.getChildAt(index - visiblePosition);  
        TextView txt = (TextView) view.findViewById(R.id.textView1);  
        // get mDataList.set(ids, item); the updated data  
        MyListItem data = (MyListItem) getItem(index);  
        // Reset the interface to display data  
        txt.setText(data.getData());  
    }  

    @Override  
    public int getCount()  
    {  
        // TODO Auto-generated method stub  
        return mDataList.size();  
    }  

    @Override  
    public Object getItem(int position)  
    {  
        // TODO Auto-generated method stub  
        return mDataList.get(position);  
    }  

    @Override  
    public long getItemId(int position)  
    {  
        // TODO Auto-generated method stub  
        return position;  
    }  

    @Override  
    public View getView(int position, View convertView, ViewGroup parent)  
    {  
        // TODO Auto-generated method stub  
        if (convertView == null)  
        {  
            convertView = LayoutInflater.from(mContext).inflate(R.layout.list_item, null);  
        }  
        TextView txt = (TextView) convertView.findViewById(R.id.textView1);  
        txt.setText(mDataList.get(position).getData());  
        return convertView;  
    }  

}  

No matter how far and hard the road ahead is, as long as the direction is right, no matter how rugged, it is closer to happiness than standing in the same place!

Spring Boot Thymeleaf ERROR 8592 org.thymeleaf.TemplateEngine

Spring Boot + Thymeleaf Error: ERROR 8592 org.thymeleaf.TemplateEngine
Error Message:
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: “class path resource [templates/…….html]”)
……ERROR 8592 — [p-nio-80-exec-7] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: “class path resource [templates/…….html]”)] with root cause
Problem location and solution
1、Location
Checked the return value of the Controller, path spelling, annotations and so on are not found problems
Fortunately, there is a page can be displayed normally, so the exchange comparison, found that the problem in the <!DOCTYPE> tag
2, solve

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Change to

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

or

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">

I think it’s puzzling, but because of the project problem, the front end can only use this webpage written with a lot of obsolete tags. Thymeleaf has strict requirements on the front end, and suggests that H5 standard be used in new projects.

extend

Here is a configuration method to turn off strict syntax checking for thymeleaf

1. In pom.xml Add dependency to file

<dependency>
   <groupId>net.sourceforge.nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.21</version>
</dependency>

2. In application.properties Add in

spring.thymeleaf.mode=LEGACYHTML5

Crypto JS decrypts malformed UTF-8 data

When using crypto JS to decrypt, an error may be reported:

Malformed UTF-8 data
Error: Malformed UTF-8 data
    at Object.stringify (d:\StudeyCode\myStudy\encryptDemo\routes\encrypt\crypto-js.js:478:27)
    at WordArray.init.toString (d:\StudeyCode\myStudy\encryptDemo\routes\encrypt\crypto-js.js:215:41)
    at decryptByDESModeCBC (d:\StudeyCode\myStudy\encryptDemo\routes\encrypt\crypto.js:90:22)
    at testSign (d:\StudeyCode\myStudy\encryptDemo\routes\test.js:34:18)
    at Layer.handle [as handle_request] (d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\layer.js:95:5)
    at next (d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\layer.js:95:5)
    at d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (d:\StudeyCode\myStudy\encryptDemo\node_modules\express\lib\router\index.js:335:12)

The reason for the error is: when des decrypts, if the encrypted data is not an integral multiple of 8, the above error will be reported,
solution: encrypt the data, and then encrypt it with Base64. When decrypting, first decrypt it with Base64, and then decrypt it with DES. The above problems can be solved.

Eclipse reported an error: an error has occurred

Eclipse reported an error: an error has occurred

When installing maven, the JDK was updated from jdk9 to jdk11. However, when opening eclipse, after selecting workspace, the loading process stopped suddenly, and then the box: an error has occurred
It’s obviously a problem with the version of JDK, so I didn’t return to jdk9, but returned to the relatively stable jdk8.

Jdk8 official download link: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Solution of duplicate entry ‘value’ for key ‘field name’ in MySQL

I. Problems:

II. Question interpretation:
Duplicate entry… for key… This error is caused by the repetition of the unique value of the primary key. This error will be reported when the unique value of the primary key is repeated during database modification or insert operation. Sometimes, this error will be reported for table operations when there are multiple identical primary keys.
(p) If you want to import data from one table into another table, you will get an error in using the primary key field.
Three, solutions:

First, if the primary key is not a required field, the primary key is not used

The second way is to remove the duplicate from the table and start the operation

Thanks for watching!

Hadoop download and install cloudera virtual machine (VM)

1.  Install VirtualBox.  Go to https://www.virtualbox.org/wiki/Downloads to download and install VirtualBox for your computer. For Windows, select the link “VirtualBox 5.1.4 for Windows hosts x86/amd64”.
2.  Download the Cloudera VM.  Download the Cloudera VM fromhttps://downloads.cloudera.com/demo_vm/virtualbox/cloudera-quickstart-vm-5.4.2-0-virtualbox.zip. The VM is over 4GB, so will take some time to download.
3.  Unzip the Cloudera VM:
Right-click cloudera-quickstart-vm-5.4.2-0-virtualbox.zip and select “Extract All…”
4.  Start VirtualBox.
5.  Begin importing. Import the VM by going to File -> Import Appliance

6.  Click the Folder icon.


7.  Select the cloudera-quickstart-vm-5.4.2-0-virtualbox. ovf from the Folder where you unzipped the VirtualBox VM and click Open.

8.  Click Next to proceed.

9.  Click Import.

10.  The virtual machine image will be imported.  This can take several minutes.

11.  Launch Cloudera VM.  When the importing is finished, the quickstart-vm-5.4.2-0 VM will appear on the left in the VirtualBox window. Select it and click the Start button to launch the VM.

12.  Cloudera VM booting.  It will take several minutes for the Virtual Machine to start. The booting process takes a long time since many Hadoop tools are started.

13.  The Cloudera VM desktop.  Once the booting process is complete, the desktop will appear with a browser.

ERROR 1010 (HY000): Error dropping database (can’t rmdir ‘./myapp’, errno: 39)

ERROR 1010 (HY000): Error dropping database (can’t rmdir ‘./ahte’, errno: 39)
Because the cold backup did not close the database before, the data file was corrupted and the data could not be qufied
Delete database prompt ~
Since it is known that the file is corrupt, the database cannot recognize it, so we go to the corresponding directory to delete the entity file
cd /data/mysql/mysql3318/data/ahte
rm -f *

Adobe audit cannot play solutions

Adobe Audition — A solution that cannot be played
Problem description (Win10 & AMP; AU6)
Adobe Audition CS6 Audition(AU) audio editing, but found a little play button on the stuck flash back (Adobe Audition CS6 has stopped working).

ready to take a look at the hardware Settings

but found a new problem: the dot Settings reported an “MME device internal error” error.

The solution



You can see that the Settings are open as normal for

Audio can also play clips
normally