Stack Overflow

Subscribe to Stack Overflow feed
most recent 30 from stackoverflow.com 2017-11-22T13:16:57Z
Updated: 9 hours 4 min ago

VBA code for changing fillcolor of shape based on value in cell

Tue, 11/21/2017 - 12:56
Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("E9")) Is Nothing Then Exit Sub If IsNumeric(Target.Value) Then If Target.Value < 0 Then ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor.RGB = vbRed Else ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor.RGB = vbGreen End If End If End Sub

In cell E9 I have the formula:

=IF(H9="";"";INDEX(Sales!E39:P39;MATCH(Main!AE3;Sales!E34:P34;0)))

This doesn't seem to work, only if I write manually for example 500 in E9. Any solutions?

How i do check if record exists in querry before outputing result

Tue, 11/21/2017 - 12:53

Have this code i want to check if 1234 exists in query before processing result I have tried this:

$pas = "1234"; $text = "12345678910111213141516"; if(empty($pas)) { echo $text; } else { if (isset($_POST["subscribe"])) { $phone = $_POST["phone"]; if ($phone == $pas) { echo $text; } else { if ($phone != "$pass") { echo erro; } } } } if(!isset($_POST["phone"]) || $_POST["phone"] != $pas) { echo '<form action="#" method="POST"> Your Phone Number <br /> <input type="text" name="phone" value="080"/> <input type="submit" name="subscribe" value="SEND PAYMENT"/> </form>'; }

But I get result even when 'pas' is not there what am I doing Wrong?

New blank tab opening unwantedly

Tue, 11/21/2017 - 12:53

I am trying to download pdf file using below code.

window.location.href = "http://www.example.com/test.pdf";

This will be placed in ajax success result. It downloaded file properly but opened unwanted blank page in new tab. Do any one faced this issue.

Please help me to resolve this problem.

I have tried even window.open(url,"_self") along with name attribute.

But not working.

Android getting current location wrong?

Tue, 11/21/2017 - 12:52

I'm new in Android development and I want to learn from my mistakes but I first need to understand what am I doing wrong here: I'm trying to get my current location

locationListener = new LocationListener() { @Override public void onLocationChanged(Location loc) { loc.getLatitude(); loc.getLongitude(); LatLng coordinate = new LatLng(loc.getLatitude(), loc.getLongitude()); CameraUpdate currentLocation = CameraUpdateFactory .newLatLngZoom(coordinate, 16); mMap.animateCamera(currentLocation); String Text = "My current location is: " + "Latitude = " + loc.getLatitude() + "Longitude = " + loc.getLongitude(); Log.d("Dana","acc="+loc.getAccuracy()); Toast.makeText(getApplicationContext(), Text, Toast.LENGTH_SHORT).show(); } @Override public void onProviderDisabled(String provider) { Toast.makeText(getApplicationContext(), "Gps Disabled", Toast.LENGTH_SHORT).show(); } @Override public void onProviderEnabled(String provider) { Toast.makeText(getApplicationContext(), "Gps Enabled", Toast.LENGTH_SHORT).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { } }; locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1); ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, 1); } locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);

but on simulator and also on my real device my location is somewhere in England, even if my phone has location activated. Why is this happening? Why is not retrieving my current real location? I've logged the accuracy and it's just 20...

Also, is there a way to store that location, even if the activity is closed? Because I've seen that when I just close the activity and reopen it doesn't call again the onLocationChanged function.

Newbie SQL: How to fetch rows *not* included in another table?

Tue, 11/21/2017 - 12:51

I'm having trouble understand JOINs. I have a list of people, and a list of attacks like this:

SELECT * FROM people; +------+--------+ | id | name | +------+--------+ | 1 | johnny | | 2 | pete | | 3 | sally | | 4 | paul | | 5 | jen | | 6 | alan | +------+--------+ SELECT * FROM attacks; +------------+----------+ | attackerId | victimId | +------------+----------+ | 1 | 2 | (johnny attacked pete) | 1 | 4 | (johnny attacked paul) | 1 | 6 | (johnny attacked alan) | 3 | 5 | (sally attacked jen) +------------+----------+

Could anybody help me figure out what command gets people not attacked by johnny like this?

+-------+ | name | +-------+ | sally | | jen | +-------+

Many thanks!

Substring the line from specific char to specific char

Tue, 11/21/2017 - 12:51

I have a string like this "4 Program Files (x86) 2" . 4 is line ID , and 2 is parent ID , the text between is the content . How can i extract each from the given string so i can create object with properties ID ,content and ParentID ?

Added columns to SQLiteDatabase, can no longer read from it

Tue, 11/21/2017 - 12:42

My SQLiteDatabase was working fine with just 3 entries, the UUID, Title and Date, but ever since I added some more columns I am getting this error.

Not sure what it can be, I have read that 0,-1 means that the column cannot be read, but I have made sure to spell all my column names correctly.

CrimeCursorWrapper.java public List<Crime> getCrimes() { List<Crime> crimes = new ArrayList<>(); CrimeCursorWrapper cursor = queryCrimes(null, null); try { cursor.moveToFirst(); while (!cursor.isAfterLast()) { crimes.add(cursor.getCrime()); cursor.moveToNext(); } } finally{ cursor.close(); } return crimes; } CrimeLab.java: public Crime getCrime(UUID id) { CrimeCursorWrapper cursor = queryCrimes( CrimeTable.Cols.UUID + " = ?", new String[] { id.toString() } ); try { if (cursor.getCount() == 0) { return null; } cursor.moveToFirst(); return cursor.getCrime(); } finally { cursor.close(); } } private static ContentValues getContentValues(Crime crime) { ContentValues values = new ContentValues(); values.put(CrimeTable.Cols.UUID, crime.getId().toString()); values.put(CrimeTable.Cols.TITLE, crime.getTitle()); values.put(CrimeTable.Cols.DATE, crime.getDate().getTime()); values.put(CrimeTable.Cols.ACTTYPE, crime.getActType().toString()); values.put(CrimeTable.Cols.PLACE, crime.getPlace().toString()); values.put(CrimeTable.Cols.DURATION, crime.getDuration().toString()); values.put(CrimeTable.Cols.COMMENT, crime.getComment().toString()); return values; } private CrimeCursorWrapper queryCrimes(String whereClause, String[] whereArgs) { Cursor cursor = mDatabase.query( CrimeTable.NAME, null, // Columns - null selects all columns whereClause, whereArgs, null, // groupBy null, // having null // orderBy ); return new CrimeCursorWrapper(cursor); } CrimeCursorWrapper.java: public class CrimeCursorWrapper extends CursorWrapper{ public CrimeCursorWrapper(Cursor cursor) { super(cursor); } public Crime getCrime() { String uuidString = getString(getColumnIndex(CrimeTable.Cols.UUID)); String title = getString(getColumnIndex(CrimeTable.Cols.TITLE)); long date = getLong(getColumnIndex(CrimeTable.Cols.DATE)); String actType = getString(getColumnIndex(CrimeTable.Cols.ACTTYPE)); String place = getString(getColumnIndex(CrimeTable.Cols.PLACE)); String duration = getString(getColumnIndex(CrimeTable.Cols.DURATION)); String comment = getString(getColumnIndex(CrimeTable.Cols.COMMENT)); Crime crime = new Crime(UUID.fromString(uuidString)); crime.setTitle(title); crime.setDate(new Date(date)); crime.setActType(actType); crime.setPlace(place); crime.setDuration(duration); crime.setComment(comment); return crime; } } Crime.java: public class Crime { private UUID mId; private String mTitle; private Date mDate; private String mActType; private String mPlace; private String mDuration; private String mComment; public Crime() { this(UUID.randomUUID()); } public Crime(UUID id) { mId = id; mDate = new Date(); } public UUID getId() { return mId; } public String getTitle() { return mTitle; } public void setTitle(String title) { mTitle = title; } public Date getDate() { return mDate; } public void setDate(Date date) { mDate = date; } public String getPhotoFilename() { return "IMG_" + getId().toString() + ".jpg"; } public String getActType() { return mActType; } public void setActType(String actType) { mActType = actType; } public String getPlace() { return mPlace; } public void setPlace(String place) { mPlace = place; } public String getDuration() { return mDuration; } public void setDuration(String duration) { mDuration = duration; } public String getComment() { return mComment; } public void setComment(String comment) { mComment = comment; } }

SQL - values from two rows into new two rows

Tue, 11/21/2017 - 12:41

I have a query that gives a sum of quantity of items on working days. on weekend and holidays that quantity value and item value is empty. I would like that on empty days is last known quantity and item. My query is like this:

`select a.dt,b.zaliha as quantity,b.artikal as item from (select to_date('01-01-2017', 'DD-MM-YYYY') + rownum -1 dt from dual connect by level <= to_date(sysdate) - to_date('01-01-2017', 'DD-MM-YYYY') + 1 order by 1)a LEFT OUTER JOIN (select kolicina,sum(kolicina)over(partition by artikal order by datum_do) as zaliha,datum_do,artikal from (select sum(vv.kolicinaulaz-vv.kolicinaizlaz)kolicina,vz.datum as datum_do,vv.artikal from vlpzaglavlja vz, vlpvarijante vv where vz.id=vv.vlpzaglavlje and vz.orgjed='01006' and vv.skladiste='01006' and vv.artikal in (3069,6402) group by vz.datum,vv.artikal order by vv.artikal,vz.datum asc) order by artikal,datum_do asc)b on a.dt=b.datum_do where a.dt between to_date('12102017','ddmmyyyy') and to_date('16102017','ddmmyyyy') order by a.dt`

and my output is like this:

and I want this:

Addhandler, removehandler

Tue, 11/21/2017 - 12:39

Let's say i do like this twice:

AddHandler grid.SelectedIndexChanged, AddressOf doSomething AddHandler grid.SelectedIndexChanged, AddressOf doSomething

From my investigatioin it will be subscribed and fire up everytime twice. Means i can subscribe same handler as much times as i want.

However does it mean when i do somewhere only once like this:

RemoveHandler grid.SelectedIndexChanged, AddressOf doSomething
  1. Would it mean i have still one "same subscriber" right therefore according to above sample handler will be called once after removing just one time?
  2. It goes to the fact that i have to always remove handler as much as i add it?
  3. What about when i execute more removehandler command for specific event than i added it?
  4. Is there any way to remove all subscribers from particural event? I am asking because

Explanation: I have huge project developed by previous developer where he always doing addhandler, remove handler from lot diffrent places... I recognized that somethimes even if at particural time shouldn't be any of subscribers left (his removehandler..) they are even run couple times same handlers are called ! The problem is the form contains "long live objects" and i am strugling with that project right now. Hope getting some help from you.

Thanks !

why i'm getting “cannot resolve method getResource()”

Tue, 11/21/2017 - 12:37

i'm trying to share image but i'm getting this error: “cannot resolve method getResource()” this is the code i'm trying to share image with:

File root = android.os.Environment.getExternalStorageDirectory(); File dir = new File (root.getAbsolutePath() + "/myFolder"); dir.mkdirs(); // build directory Random generator = new Random(); int n = 10000; n = generator.nextInt(n); String fileName = "Image-"+ n +".jpg"; File file = new File(dir, fileName); if (file.exists ()) file.delete (); try { FileOutputStream outStream = new FileOutputStream(file); InputStream is; Bitmap bitmap; is = this.getResources().openRawResource(R.drawable.image1); bitmap = BitmapFactory.decodeStream(is); try { is.close(); is = null; } catch (IOException e) { } bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream); outStream.flush(); outStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_SEND); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_STREAM, outputFileUri); startActivity(Intent.createChooser(intent, "Share this image via"));

. . .

ORA-03146: Invalid buffer length for TTC field

Tue, 11/21/2017 - 12:35

when I try to insert record to the table, I get the following error. I do not have any problems when I perform update and select operations for the same table.

Nhibernate Proviler Insert Command :

> INSERT INTO UserOneTimePassword > (Id, > Password, > TryCount, > CreatedOn, > CreatedBy, > ModifiedBy, > ModifiedOn, > UserId) VALUES (hibernate_sequence.nextval, > '''5618e6e426cffa1136bd078d0c875a81f1e1edd84a74980dfec579007d225424'' > [Type: String (0:0:0)]' /* :p0 */, > '0 [Type: Int32 (0:0:0)]' /* :p1 */, > '2017-11-21T09:42:34.0000000 [Type: DateTime (0:0:0)]' /* :p2 */, > '0 [Type: Int64 (0:0:0)]' /* :p3 */, > 'NULL [Type: Int64 (0:0:0)]' /* :p4 */, > 'NULL [Type: DateTime (0:0:0)]' /* :p5 */, > '7 [Type: Int64 (0:0:0)], :nhIdOutParam = NULL [Type: Int64 (0:0:0)]' /* :p6 */) returning Id into :nhIdOutParam

Error :

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-03146: TTC alanı için geçersiz arabellek uzunluğu at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone) at OracleInternal.ServiceObjects.OracleCommandImpl.ExecuteNonQuery(String commandText, OracleParameterCollection paramColl, CommandType commandType, OracleConnectionImpl connectionImpl, Int32 longFetchSize, Int64 clientInitialLOBFS, OracleDependencyImpl orclDependencyImpl, Int64[]& scnFromExecution, OracleParameterCollection& bindByPositionParamColl, Boolean& bBindParamPresent, OracleException& exceptionForArrayBindDML, OracleConnection connection, OracleLogicalTransaction& oracleLogicalTransaction, Boolean isFromEF) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteNonQuery()
at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Id.Insert.OutputParamReturningDelegate.ExecuteAndExtract(IDbCommand insert, ISessionImplementor session) at NHibernate.Id.Insert.AbstractReturningDelegate.PerformInsert(SqlCommandInfo insertSQL, ISessionImplementor session, IBinder binder)

Selenium fails to start Chromedriver - Ubuntu 16.04, Python 3.6.3

Tue, 11/21/2017 - 12:26
from selenium import webdriver browser = webdriver.Chrome() browser.get('http://www.google.com')

It never actually reaches this and fails with:

root@server:~# python /root/EmailBot/main.py Traceback (most recent call last): File "/root/EmailBot/main.py", line 22, in <module> browser = webdriver.Chrome() File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__ desired_capabilities=desired_capabilities) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 151, in __init__ self.start_session(desired_capabilities, browser_profile) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 240, in start_session response = self.execute(Command.NEW_SESSION, parameters) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.4.0-101-generic x86_64)

of importance:

root@server:~# which chromedriver /usr/local/bin/chromedriver root@server:~# ll /usr/local/bin/chromedriver -rwxr-xr-x 1 root root 8950080 Oct 3 14:09 /usr/local/bin/chromedriver* root@server:~# google-chrome --version Google Chrome 62.0.3202.94

I have tried EVERY thread I can find and no solutions are working. I'm not sure if this is because it is a python 3.6 problem?

How to find the size of buffer/cache used in file system of Linux?

Tue, 11/21/2017 - 12:11
root@ubuntu:~# free -wh total used free shared buffers cache available Mem: 2.0G 51M 1.7G 3.2M 20M 190M 1.8G Swap: 2.0G 0B 2.0G

190 is the size of cache used, but I want to know the total size of cache in this system.

Hibernate Template throwing error while Autowirring

Tue, 11/21/2017 - 11:07

Currently I'm facing an issue in Autowire configuration between controller and the HibernateTemplate.

I'm unable to trace my mistakes.

I Want to do Autowired Hibernate Template But It gives this error can implementation of hibernate template is required to provide manually

bellow i given my dispatcher servlet, java controller and error

this one is my dispatcher servlet code <beans xmlns = "http://www.springframework.org/schema/beans" xmlns:context = "http://www.springframework.org/schema/context" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:component-scan base-package = "com.chatbot.controllers" /> <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name = "prefix" value = "/" /> <property name = "suffix" value = ".jsp" /> </bean> <!-- Hibernate Configuration --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://192.168.0.46:3306/chatbotadmin" /> <property name="username" value="root" /> <property name="password" value="" /> </bean> <!-- Hibernate template configuration --> <bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <property name="annotatedClasses"> <list> <value>com.chatbot.beans.QueryBean</value> <value>com.chatbot.beans.PatternBean</value> <value>com.chatbot.beans.OptionsBean</value> <value>com.chatbot.beans.OperationBean</value> <value>com.chatbot.beans.ResponseBean</value> </list> </property> </bean> <bean id="template" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> </beans> code for java controller public class AddOperations { @Autowired(required = true) HibernateTemplate t; @RequestMapping(value="/addoperations",method=RequestMethod.GET) public ModelAndView addItGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, JSONException { JSONObject responseString = call(request,response); System.out.println(responseString); return new ModelAndView("AdminPanal","QueryRecords",responseString.toString()); } @RequestMapping(value="/addoperations",method=RequestMethod.POST) public void addItPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException, JSONException { JSONObject responseString = call(request,response); System.out.println(responseString); response.getWriter().println(responseString); } @SuppressWarnings("unchecked") private JSONObject call(HttpServletRequest request, HttpServletResponse response) throws JSONException { // TODO Auto-generated method stub if(request.getParameter("data")!=null) { try { System.out.println("Operation REQ==> "+ request.getParameter("data")); JSONObject parsedRequest = Constant.getparsedRequest(request.getParameter("data")); JSONArray arrayOfOperations = new JSONArray(parsedRequest.getString("Operations")); String OPERATIONTITLE = new String(); String OPERATIONURL = new String(); String OPERATIONPARAMETERS = new String(); int LEVEL=0; int QID=0; if(parsedRequest.getString("QID").equals("")) { JSONObject jsonObject = new JSONObject(); jsonObject.put("status", "false"); jsonObject.put("message", "QID is blank..!!"); return jsonObject; } else { if(arrayOfOperations.length()>0) { QID = Integer.parseInt(parsedRequest.getString("QID")); List<QueryBean> list = t.find("FROM QueryBean q where q.QID="+QID); ArrayList<OperationBean> arrayList = new ArrayList<>(); if(list.size()!=0) { int count =0; List<ResponseBean> queryResponse_check = t.find("FROM ResponseBean r where r.queryBean = "+list.get(0)); if(queryResponse_check.size()>0) { JSONObject jsonObject = new JSONObject(); jsonObject.put("status", "false"); jsonObject.put("message", "Response already exist..!!"); return jsonObject; } else { for(int i=0; i<arrayOfOperations.length(); i++) { JSONObject jsonObject = arrayOfOperations.getJSONObject(i); if(!jsonObject.getString("OPERATIONTITLE").equals("")) { OPERATIONTITLE = jsonObject.getString("OPERATIONTITLE"); OPERATIONURL = jsonObject.getString("OPERATIONURL"); OPERATIONPARAMETERS = jsonObject.getString("OPERATIONPARAMETERS"); LEVEL = jsonObject.getInt("LEVEL"); OperationBean OperationBean = new OperationBean(list.get(0), OPERATIONTITLE, OPERATIONURL, OPERATIONPARAMETERS,LEVEL, new Date(), new Date(), ""); arrayList.add(OperationBean); for(int i1=0; i1<arrayList.size(); i1++) count = (int) t.save(arrayList.get(i1)); } } if(count !=0) { JSONObject jsonObject = new JSONObject(); jsonObject.put("status", "true"); jsonObject.put("message", "Response added successfully..!!"); return jsonObject; } } } } else { } } } catch(JSONException je) { je.printStackTrace(); } } return null; } } Error given by compiler is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addOperations': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.orm.hibernate3.HibernateTemplate com.chatbot.controllers.AddOperations.t; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.orm.hibernate3.HibernateTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1174) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1090) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:980) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4829) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415) at java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415) at java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:671) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495) Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.orm.hibernate3.HibernateTemplate com.chatbot.controllers.AddOperations.t; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.orm.hibernate3.HibernateTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:506) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) ... 50 more Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.orm.hibernate3.HibernateTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478) ... 52 more Nov 21, 2017 4:03:52 PM org.apache.catalina.core.StandardContext loadOnStartup SEVERE: Servlet [Demo_dispatcher] in web application [/DemoSpring] threw load() exception org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.orm.hibernate3.HibernateTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:924) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:793) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:284) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1174) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1090) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:980) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4829) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5139) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415) at java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1425) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1415) at java.util.concurrent.FutureTask.run(Unknown Source) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) at java.util.concurrent.AbstractExecutorService.submit(Unknown Source) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:941) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) at org.apache.catalina.startup.Catalina.start(Catalina.java:671) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)

How to add scroll bar to the table body using DataTables plugin

Tue, 11/21/2017 - 10:07

I am using dataTables plugin to show my data in table, but when I add scroll bar to the table body, table header looks like datatable header I found solution in Datatable documentation they suggest to add 2 lines

$(".dataTables_scrollHeadInner").css({"width":"100%"}); $(".table ").css({"width":"100%"});

but when I add these two lines in javascript, the table alignment looks bad. Could anyone please help me to add a scroll bar to the datatable body

Java Script:

$('#protein-table').DataTable({ scrollY:'400px', scrollCollapse:true, ordering: false, });

MySQL Crosstab Query for Profile Table

Tue, 11/21/2017 - 07:25

I have the following table.

CREATE TABLE `profiles` ( `id` int(11) NOT NULL, `user` varchar(50) NOT NULL, `field` varchar(50) NOT NULL, `value` varchar(50) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--

-- Dumping data for table profiles INSERT INTO `profiles` (`id`, `user`, `field`, `value`) VALUES (1, 'jd', 'Name', 'John Doe'), (2, 'jd', 'Phone', '0300000000'), (3, 'rm', 'Name', 'Roger Moore'), (4, 'rm', 'Phone', '03111111111');

I want to view the data as below.

Name | Phone Johns Doe | 0300000000 Roger Moore | 03111111111

How to Prevent Json Call even on Refresh until new Data is available [on hold]

Tue, 11/21/2017 - 05:11

Title says it all... I'm new to coding and I just want as simple as an answer as it can be. I have a weather api, but it is limited on calls each refresh acts as a call, but the forecast updates daily. Anyway around this to maximize my calls? I can post my js code and html if necessary. Apparently people are quick to judge on here....

Error with Java String in declaration in intellij

Tue, 11/21/2017 - 00:50

I've updated my intellij to 2017.2.5 and imported all the projects. For some reason, declaration and constructors show some error with Strings. e.g. private String type = "abc"; and name = " xyz"; Error asks me to change it to java.lang.string as a solution.

Jdk is up to date. libraries are up to date, so what is the problem? Project structure looks ok. How do I fix this?

issue pic

Code for Monotone Cubic Interpolation wrong?

Tue, 11/21/2017 - 00:50

Am trying to implement a spline interpolation function. My favorite is the Monotone Cubic variant because it prevents the values from exceeding over or below the desired points as seen here:

I've used the code from here (of course I will provide credits in the final open source project): https://gist.github.com/lecho/7627739

However when feeding it with the following points:

X : Y 0.0 : 0.0 30.0 : 100 40.0 : 0.0

I get a spline with the following interpolation:

Interpolated points: 0 : 0.0 Interpolated points: 1 : 3.5481482 Interpolated points: 2 : 7.4962964 Interpolated points: 3 : 11.799999 Interpolated points: 4 : 16.414816 Interpolated points: 5 : 21.296297 Interpolated points: 6 : 26.400002 Interpolated points: 7 : 31.681482 Interpolated points: 8 : 37.0963 Interpolated points: 9 : 42.600006 Interpolated points: 10 : 48.14815 Interpolated points: 11 : 53.6963 Interpolated points: 12 : 59.2 Interpolated points: 13 : 64.614815 Interpolated points: 14 : 69.89629 Interpolated points: 15 : 75.0 Interpolated points: 16 : 79.881485 Interpolated points: 17 : 84.49629 Interpolated points: 18 : 88.8 Interpolated points: 19 : 92.748146 Interpolated points: 20 : 96.296295 Interpolated points: 21 : 99.4 Interpolated points: 22 : 102.01482 Interpolated points: 23 : 104.09629 Interpolated points: 24 : 105.6 Interpolated points: 25 : 106.48148 Interpolated points: 26 : 106.6963 Interpolated points: 27 : 106.200005 Interpolated points: 28 : 104.94815 Interpolated points: 29 : 102.89629 Interpolated points: 30 : 100.0 Interpolated points: 31 : 95.4 Interpolated points: 32 : 88.53333 Interpolated points: 33 : 79.8 Interpolated points: 34 : 69.600006 Interpolated points: 35 : 58.333332 Interpolated points: 36 : 46.399994 Interpolated points: 37 : 34.200005 Interpolated points: 38 : 22.133331 Interpolated points: 39 : 10.600002 Interpolated points: 40 : 0.0

So obviously it "swings" above the largest point (100). isn't it exactly this effect the "monotinic" approach should prevent? For some reason if I use the points

0:0 20:100 40:0

so the peak is exactly centered, the result is correct. Does that mean the algorithm always requires the points to have the same distance on the X-Axis?

If so, does anyone know some other open-source implementation which works with any points?

Huge thanks in advance!

how to get documents from mongoDB based on greater or less than the given date

Tue, 11/21/2017 - 00:50

I need one help. I need to get the record from mongoDB based on the date using mongoDB. I am explaining my collection below.

f_task:

{ "_id": "5a13731f9402cc17f81ade10", "taskname": "task1", "description": "description", "timestamp": "2017-11-21 05:58:14", "created_by": "subhra", "taskid": "858fca9e2e153a61515c0372e079c521", "created_date": "21-11-2017" }

Here i need to fetch record as per created_date. suppose user input is 20-11-2017 or 22-11-2017 then I need query to get the record if the given date is greater than or less than the "created_date" value.Please help.

Pages