Posts

Showing posts with the label substring

What is the cause of my IndexOutOfBoundsException

What is the cause of my IndexOutOfBoundsException I am trying to upload a file using primefaces and hibernate. My managed bean has the following function: public void upload(){ if(file != null){ try { FacesContext context = FacesContext.getCurrentInstance(); ServletContext servletContext = (ServletContext) context.getExternalContext().getContext(); String dbPath = servletContext.getRealPath("/"); String webcut = dbPath.substring(0, dbPath.lastIndexOf("\")); String buildcut = webcut.substring(0, webcut.lastIndexOf("\")); String mainURLPath = buildcut.substring(0, buildcut.lastIndexOf("\")); InputStream inputStream = file.getInputstream(); String path = mainURLPath + "\web\resources\images" + file.getFileName(); File destFile = new File(path); if(!destFile.exists()){ FileUtils.copyInputStreamT...

Remove substring from one column in Mysql

Remove substring from one column in Mysql I want to delete a part of the substring from my table's column For example, I have a structure like the following: id | Col1 ____________________________________________________________ 1 | The string I want and the string I don't And I need to update my table such that: id | Col1 ____________________________________________________________ 1 | The string I want I tried using the following code: $var = "UPDATE mytable SET col1 = replace(col1,col1(SUBSTRING(col1,19),'')"; But this won't work! Things to research Substring,substring_index,replace – P.Salmon Jul 1 at 11:04 1 Answer 1 Try this query to separ...