问:
Cant add data to databases on Spring Boot using Heroku postgres
I've been trying to get a Rest Repository up and running using Heroku.  However, while the tables I'm using are being added to the datasource, I am unable to upload any rows of data.

Shows that my tables are being added to postgres datasource

I don't get any error messages or issues deploying the service, I just can't add data.

I've looked around the internet for solutions currently application.properties is a mess of different bits of code that I've copied on all the guides for how to get a database running.

```<code>#spring.h2.console.enabled=true
#spring.datasource.url=jdbc:h2:mem:testdb
#spring.datasource.driverClassName=org.h2.Driver
#spring.datasource.username=sa
#spring.datasource.password=
#spring.h2.console.settings.web-allow-others=true

#spring.main.banner-mode=off
#logging.level.org.springframework=ERROR

spring.jpa.hibernate.ddl-auto=update

#spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
#spring.datasource.url=postgres://npwovtbfrmcgap:8cb0a1d61d6608e756d4340bb79926156b43c5d602580ab21884d058b7adf230@ec2-52-23-14-156.compute-1.amazonaws.com:5432/deu5uhuf0in93s
#spring.datasource.url=${JDBC_DATABASE_URL}
#spring.datasource.username=${SPRING_DATABASE_USERNAME}
#spring.datasource.password=${SPRING_DATABASE_PASSWORD}
#spring.jpa.show-sql=true
#spring.jpa.generate-ddl=true
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
spring.jpa.show-sql=false
spring.jpa.generate-ddl=true
</code>```

For testing I used h2 and that worked fine with no issues.  Even though I've been eyeing using JDBC _DATABASE for it's easy setup, I've made a Database Configuration file.

```<code>package com.example.chess.Config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DatabaseConfig {

    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource()
    {
        return new org.apache.tomcat.jdbc.pool.DataSource();
    }
}
</code>```

There isn't a whole lot here, but from my understanding I shouldn't need one if I'm using a JDBC Database.

Some ideas that I have...

Heroku could be forcing me to use their guide on preparing a Spring Boot App for production
https://devcenter.heroku.com/articles/preparing-a-spring-boot-app-for-production-on-heroku

I could put better @GeneratedValue typing on the code for tables I have.

```<code>package com.example.chess.Model;

import javax.persistence.*;

@Entity
public class Chat {

    @GeneratedValue
    @Id
    @Column
    private int chatID;

    @Column
    private String chatMsg;

    public int getChatID() {
        return chatID;
    }

    public String getChatMsg() {
        return chatMsg;
    }

    public void setChatID(int chatID) {
        this.chatID = chatID;
    }

    public void setChatMsg(String chatMsg) {
        this.chatMsg = chatMsg;
    }
}
</code>```

Past that I'm not really sure what to do.  Any feedback is appreciated.

Thanks for all the help, however I still havent gotten it working.  I used heroku logs to find more data.  I also used spring.database.platform and spring.datasource.driver-class-name.  the code for application properties has been updated.

```<code>2020-02-18T02:22:38.000000+00:00 app[api]: Build succeeded
2020-02-18T02:22:41.021726+00:00 app[web.1]: 2020-02-18 02:22:41.017  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:41.264675+00:00 app[web.1]:
2020-02-18T02:22:41.264732+00:00 app[web.1]: .   ____          _            __ _ _
2020-02-18T02:22:41.264786+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-02-18T02:22:41.264849+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-02-18T02:22:41.264905+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-02-18T02:22:41.264972+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-02-18T02:22:41.265009+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-02-18T02:22:41.265886+00:00 app[web.1]: :: Spring Boot ::        (v2.1.7.RELEASE)
2020-02-18T02:22:41.265938+00:00 app[web.1]:
2020-02-18T02:22:41.335856+00:00 app[web.1]: 2020-02-18 02:22:41.335  INFO 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-18T02:22:41.566210+00:00 app[web.1]: 2020-02-18 02:22:41.565  INFO 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2020-02-18T02:22:41.566423+00:00 app[web.1]: 2020-02-18 02:22:41.566  WARN 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2020-02-18T02:22:41.570798+00:00 app[web.1]: 2020-02-18 02:22:41.570  INFO 4 --- [           main] com.example.chess.ChessApplication       : No active profile set, falling back to default profiles: default
2020-02-18T02:22:42.945648+00:00 app[web.1]: 2020-02-18 02:22:42.943  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-02-18T02:22:43.135659+00:00 app[web.1]: 2020-02-18 02:22:43.135  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 157ms. Found 4 repository interfaces.
2020-02-18T02:22:43.711365+00:00 app[web.1]: 2020-02-18 02:22:43.711  INFO 4 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=de70dafe-40e0-316f-93ef-ef4b324ee017
2020-02-18T02:22:43.965692+00:00 app[web.1]: 2020-02-18 02:22:43.965  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cdb9cd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.025903+00:00 app[web.1]: 2020-02-18 02:22:44.025  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.561043+00:00 app[web.1]: 2020-02-18 02:22:44.560  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 37710 (http)
2020-02-18T02:22:44.670131+00:00 app[web.1]: 2020-02-18 02:22:44.669  INFO 4 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-18T02:22:44.670471+00:00 app[web.1]: 2020-02-18 02:22:44.670  INFO 4 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.22]
2020-02-18T02:22:45.421352+00:00 app[web.1]: 2020-02-18 02:22:45.421  INFO 4 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-18T02:22:45.421626+00:00 app[web.1]: 2020-02-18 02:22:45.421  INFO 4 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3826 ms
2020-02-18T02:22:45.859027+00:00 app[web.1]: 2020-02-18 02:22:45.858  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-02-18T02:22:46.292693+00:00 app[web.1]: 2020-02-18 02:22:46.292  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-02-18T02:22:46.414129+00:00 app[web.1]: 2020-02-18 02:22:46.413  INFO 4 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
2020-02-18T02:22:46.414131+00:00 app[web.1]: name: default
2020-02-18T02:22:46.414131+00:00 app[web.1]: ...]
2020-02-18T02:22:46.563652+00:00 app[web.1]: 2020-02-18 02:22:46.563  INFO 4 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final}
2020-02-18T02:22:46.566628+00:00 app[web.1]: 2020-02-18 02:22:46.566  INFO 4 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2020-02-18T02:22:46.824490+00:00 app[web.1]: 2020-02-18 02:22:46.824  INFO 4 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2020-02-18T02:22:47.331763+00:00 app[web.1]: 2020-02-18 02:22:47.331  INFO 4 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-02-18T02:22:47.616894+00:00 app[web.1]: 2020-02-18 02:22:47.616  INFO 4 --- [           main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true
2020-02-18T02:22:47.624236+00:00 app[web.1]: 2020-02-18 02:22:47.623  INFO 4 --- [           main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@37e4d7bb
2020-02-18T02:22:48.869877+00:00 app[web.1]: 2020-02-18 02:22:48.869  INFO 4 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-18T02:22:49.329464+00:00 app[web.1]: 2020-02-18 02:22:49.329  INFO 4 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2020-02-18T02:22:50.308149+00:00 app[web.1]: 2020-02-18 02:22:50.307  INFO 4 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-18T02:22:50.411820+00:00 app[web.1]: 2020-02-18 02:22:50.409  WARN 4 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-18T02:22:50.461378+00:00 app[web.1]: 2020-02-18 02:22:50.461  INFO 4 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2020-02-18T02:22:51.073701+00:00 heroku[web.1]: State changed from starting to up
2020-02-18T02:22:50.863588+00:00 app[web.1]: 2020-02-18 02:22:50.863  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 37710 (http) with context path ''
2020-02-18T02:22:50.865846+00:00 app[web.1]: 2020-02-18 02:22:50.865  INFO 4 --- [           main] com.example.chess.ChessApplication       : Started ChessApplication in 12.027 seconds (JVM running for 12.976)
</code>```

答:
Finally fixed it.  Boy do I feel dumb, the problem was in the angular frontend I was posting and getting from localhost:8080.

```<code>$http.get("http://localhost:8080/letter").then(function (response){

        $scope.letter = response.data;

    });

  $scope.postLetter = function(letter)
  {
      var data = {
          contactName: contactName,
          email: email,
          message: message
      };
      $http.post("http://localhost:8080/letter", JSON.stringify(data));
      location.reload();
  };
</code>```

Thanks again for everyone who tried helping.

Body:
I've been trying to get a Rest Repository up and running using Heroku.  However, while the tables I'm using are being added to the datasource, I am unable to upload any rows of data.

Shows that my tables are being added to postgres datasource

I don't get any error messages or issues deploying the service, I just can't add data.

I've looked around the internet for solutions currently application.properties is a mess of different bits of code that I've copied on all the guides for how to get a database running.

#spring.h2.console.enabled=true
#spring.datasource.url=jdbc:h2:mem:testdb
#spring.datasource.driverClassName=org.h2.Driver
#spring.datasource.username=sa
#spring.datasource.password=
#spring.h2.console.settings.web-allow-others=true

#spring.main.banner-mode=off
#logging.level.org.springframework=ERROR

spring.jpa.hibernate.ddl-auto=update

#spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
#spring.datasource.url=postgres://npwovtbfrmcgap:8cb0a1d61d6608e756d4340bb79926156b43c5d602580ab21884d058b7adf230@ec2-52-23-14-156.compute-1.amazonaws.com:5432/deu5uhuf0in93s
#spring.datasource.url=${JDBC_DATABASE_URL}
#spring.datasource.username=${SPRING_DATABASE_USERNAME}
#spring.datasource.password=${SPRING_DATABASE_PASSWORD}
#spring.jpa.show-sql=true
#spring.jpa.generate-ddl=true
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.username=${JDBC_DATABASE_USERNAME}
spring.datasource.password=${JDBC_DATABASE_PASSWORD}
spring.jpa.show-sql=false
spring.jpa.generate-ddl=true

For testing I used h2 and that worked fine with no issues.  Even though I've been eyeing using JDBC _DATABASE for it's easy setup, I've made a Database Configuration file.

package com.example.chess.Config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DatabaseConfig {

    @Bean
    @Primary
    @ConfigurationProperties(prefix = "spring.datasource")
    public DataSource dataSource()
    {
        return new org.apache.tomcat.jdbc.pool.DataSource();
    }
}

There isn't a whole lot here, but from my understanding I shouldn't need one if I'm using a JDBC Database.

Some ideas that I have...

Heroku could be forcing me to use their guide on preparing a Spring Boot App for production
https://devcenter.heroku.com/articles/preparing-a-spring-boot-app-for-production-on-heroku

I could put better @GeneratedValue typing on the code for tables I have.

package com.example.chess.Model;

import javax.persistence.*;

@Entity
public class Chat {

    @GeneratedValue
    @Id
    @Column
    private int chatID;

    @Column
    private String chatMsg;

    public int getChatID() {
        return chatID;
    }

    public String getChatMsg() {
        return chatMsg;
    }

    public void setChatID(int chatID) {
        this.chatID = chatID;
    }

    public void setChatMsg(String chatMsg) {
        this.chatMsg = chatMsg;
    }
}

Past that I'm not really sure what to do.  Any feedback is appreciated.

Thanks for all the help, however I still havent gotten it working.  I used heroku logs to find more data.  I also used spring.database.platform and spring.datasource.driver-class-name.  the code for application properties has been updated.

2020-02-18T02:22:38.000000+00:00 app[api]: Build succeeded
2020-02-18T02:22:41.021726+00:00 app[web.1]: 2020-02-18 02:22:41.017  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:41.264675+00:00 app[web.1]:
2020-02-18T02:22:41.264732+00:00 app[web.1]: .   ____          _            __ _ _
2020-02-18T02:22:41.264786+00:00 app[web.1]: /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
2020-02-18T02:22:41.264849+00:00 app[web.1]: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
2020-02-18T02:22:41.264905+00:00 app[web.1]: \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
2020-02-18T02:22:41.264972+00:00 app[web.1]: '  |____| .__|_| |_|_| |_\__, | / / / /
2020-02-18T02:22:41.265009+00:00 app[web.1]: =========|_|==============|___/=/_/_/_/
2020-02-18T02:22:41.265886+00:00 app[web.1]: :: Spring Boot ::        (v2.1.7.RELEASE)
2020-02-18T02:22:41.265938+00:00 app[web.1]:
2020-02-18T02:22:41.335856+00:00 app[web.1]: 2020-02-18 02:22:41.335  INFO 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888
2020-02-18T02:22:41.566210+00:00 app[web.1]: 2020-02-18 02:22:41.565  INFO 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888. Will be trying the next url if available
2020-02-18T02:22:41.566423+00:00 app[web.1]: 2020-02-18 02:22:41.566  WARN 4 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/application/default": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2020-02-18T02:22:41.570798+00:00 app[web.1]: 2020-02-18 02:22:41.570  INFO 4 --- [           main] com.example.chess.ChessApplication       : No active profile set, falling back to default profiles: default
2020-02-18T02:22:42.945648+00:00 app[web.1]: 2020-02-18 02:22:42.943  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2020-02-18T02:22:43.135659+00:00 app[web.1]: 2020-02-18 02:22:43.135  INFO 4 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 157ms. Found 4 repository interfaces.
2020-02-18T02:22:43.711365+00:00 app[web.1]: 2020-02-18 02:22:43.711  INFO 4 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=de70dafe-40e0-316f-93ef-ef4b324ee017
2020-02-18T02:22:43.965692+00:00 app[web.1]: 2020-02-18 02:22:43.965  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$cdb9cd1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.025903+00:00 app[web.1]: 2020-02-18 02:22:44.025  INFO 4 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$28f59fce] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-02-18T02:22:44.561043+00:00 app[web.1]: 2020-02-18 02:22:44.560  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 37710 (http)
2020-02-18T02:22:44.670131+00:00 app[web.1]: 2020-02-18 02:22:44.669  INFO 4 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-02-18T02:22:44.670471+00:00 app[web.1]: 2020-02-18 02:22:44.670  INFO 4 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.22]
2020-02-18T02:22:45.421352+00:00 app[web.1]: 2020-02-18 02:22:45.421  INFO 4 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-02-18T02:22:45.421626+00:00 app[web.1]: 2020-02-18 02:22:45.421  INFO 4 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3826 ms
2020-02-18T02:22:45.859027+00:00 app[web.1]: 2020-02-18 02:22:45.858  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-02-18T02:22:46.292693+00:00 app[web.1]: 2020-02-18 02:22:46.292  INFO 4 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-02-18T02:22:46.414129+00:00 app[web.1]: 2020-02-18 02:22:46.413  INFO 4 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
2020-02-18T02:22:46.414131+00:00 app[web.1]: name: default
2020-02-18T02:22:46.414131+00:00 app[web.1]: ...]
2020-02-18T02:22:46.563652+00:00 app[web.1]: 2020-02-18 02:22:46.563  INFO 4 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.3.10.Final}
2020-02-18T02:22:46.566628+00:00 app[web.1]: 2020-02-18 02:22:46.566  INFO 4 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2020-02-18T02:22:46.824490+00:00 app[web.1]: 2020-02-18 02:22:46.824  INFO 4 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2020-02-18T02:22:47.331763+00:00 app[web.1]: 2020-02-18 02:22:47.331  INFO 4 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-02-18T02:22:47.616894+00:00 app[web.1]: 2020-02-18 02:22:47.616  INFO 4 --- [           main] o.h.e.j.e.i.LobCreatorBuilderImpl        : HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true
2020-02-18T02:22:47.624236+00:00 app[web.1]: 2020-02-18 02:22:47.623  INFO 4 --- [           main] org.hibernate.type.BasicTypeRegistry     : HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@37e4d7bb
2020-02-18T02:22:48.869877+00:00 app[web.1]: 2020-02-18 02:22:48.869  INFO 4 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-02-18T02:22:49.329464+00:00 app[web.1]: 2020-02-18 02:22:49.329  INFO 4 --- [           main] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2020-02-18T02:22:50.308149+00:00 app[web.1]: 2020-02-18 02:22:50.307  INFO 4 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-02-18T02:22:50.411820+00:00 app[web.1]: 2020-02-18 02:22:50.409  WARN 4 --- [           main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-02-18T02:22:50.461378+00:00 app[web.1]: 2020-02-18 02:22:50.461  INFO 4 --- [           main] o.s.b.a.w.s.WelcomePageHandlerMapping    : Adding welcome page: class path resource [static/index.html]
2020-02-18T02:22:51.073701+00:00 heroku[web.1]: State changed from starting to up
2020-02-18T02:22:50.863588+00:00 app[web.1]: 2020-02-18 02:22:50.863  INFO 4 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 37710 (http) with context path ''
2020-02-18T02:22:50.865846+00:00 app[web.1]: 2020-02-18 02:22:50.865  INFO 4 --- [           main] com.example.chess.ChessApplication       : Started ChessApplication in 12.027 seconds (JVM running for 12.976)

Body:
Finally fixed it.  Boy do I feel dumb, the problem was in the angular frontend I was posting and getting from localhost:8080.

$http.get("http://localhost:8080/letter").then(function (response){

        $scope.letter = response.data;

    });

  $scope.postLetter = function(letter)
  {
      var data = {
          contactName: contactName,
          email: email,
          message: message
      };
      $http.post("http://localhost:8080/letter", JSON.stringify(data));
      location.reload();
  };

Thanks again for everyone who tried helping.


来源: stackexchange

问:
typescript custom component function param throwing warning
I have this piece of code

```<code><GoogleLogin
  onSuccess={responseGoogle => {
    const { email, name } = responseGoogle.profileObj; // error: Property 'profileObj' does not exist on type 'GoogleLoginResponse | GoogleLoginResponseOffline'.
  }}
/>
</code>```

The library is here https://www.npmjs.com/package/react-google-login

What should I do? I tried (responseGoogle:any) it doesn't work.

答:
Try this</p>

```<code><GoogleLogin
  onSuccess={({ profileObj: { email, name } = {} }: any) => {
    // use email and name
  }
/>
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have this piece of code

<GoogleLogin
  onSuccess={responseGoogle => {
    const { email, name } = responseGoogle.profileObj; // error: Property 'profileObj' does not exist on type 'GoogleLoginResponse | GoogleLoginResponseOffline'.
  }}
/>

The library is here https://www.npmjs.com/package/react-google-login

What should I do? I tried (responseGoogle:any) it doesn't work.

Body:
Try this

<GoogleLogin
  onSuccess={({ profileObj: { email, name } = {} }: any) => {
    // use email and name
  }
/>


问:
Is it possible (any built in function especially) to make only *some* of the text in a textbox editable in VB6?
Right now my company is asking me to analyze using a textbox that we use already for generic comments in Visual Studio 2015 VB6. They want to include some sort of tag to indicate something in that textbox, lets say tag or no tag.

Basically, if Condition 1 is true, I want to know if I can have tag appear at the beginning of the textbox string, and still be able to change everything after this tag, but leave the tag there and undeletable, not able to mess it up, keep it at the beginning of the string.

I'm thinking to have a boolean that represents if the tag is there. If it is true, and the tag is 5 characters, I can handle all the user interactions with events.

Ex. User trying to backspace all the way through tag. If boolean is true, then I can check the index at every keypress or maybe keydown etc and if the index is 5 then ignore the delete. Also Every time we enter that text box, through tabbing, or clicking, manually (if that boolean is true) set the cursor position TO 5, so they can only enter after.

There are more scenarios, like if the user highlights part of the tag and further text and tries to delete etc.

I need to do more thinking on this if I need to do it this way to nail it down, but I feel like it is technically possible, although kinda specific and it seems a little silly.

Is there a more elegant solution?
 Am I allowed to ask, if you all would bother going down this route (too bug prone, bad coding practice?, not good for future coders?) , or just suggesting a label nearby instead? (since that question may be opinion based)

This is my first question. Please feel free to give me feedback, if I didn't put enough work into it I'll understand, or If I left out vital details or it doesn't make sense let me know.  I know I didn't show specific code for handling this. I'm more concerned with the general idea and if I need to step back and take a completely different approach.

答: You could check the text length of the tag since it is placed in the beginning of the string and allow edits only if the current cursor position in the textbox is larger than the tag length.</p>


问:
*ngFor on ng-template outputs nothing Angular2
Not sure why my *ngFor loop is printing nothing out. I have the following code in an html file:

```<code><table class="table table-hover">
    <thead>
        <tr>
            <th>Name</th>
            <th>Email</th>
            <th>Company</th>
            <th>Status</th>
        </tr>
    </thead>
    <tbody>
        <!-- NGFOR ATTEMPTED HERE -- no content printed -->
        <ng-template *ngFor="let xb of tempData">
            <tr data-toggle="collapse" data-target="#demo1" class="accordion-toggle">
                <td>{{ xb.name }}</td>
                <td>{{ xb.email }}</td>
                <td>{{ xb.company }}</td>
                <td>{{ xb.status }}</td>
            </tr>
            <!-- other content -->
        </ng-template>
    </tbody>
</table>
</code>```

Then, in my simple component I have the following:

```<code>import { Component }        from '@angular/core';

@Component({
    selector: 'my-profile-exhibitors',
    templateUrl: './profile-exhibitors.component.html',
    styleUrls: ['./profile-exhibitors.component.scss']
})
export class ProfileExhibitorsComponent {
    public tempData: any = [
        {
            'name': 'name1',
            'email': 'email1@gmail',
            'company': 'company',
            'status': 'Complete'
        },
        {
            'name': 'name2',
            'email': 'email2@gmail',
            'company': 'company',
            'status': 'Incomplete'
        }
    ];
    constructor() {}
}
</code>```

When I run this code, I get zero output. Even weirder is that when I select the element using debug tools I see this:

Looks like it correctly recognizes my object, but then outputs nothing.

答: For getting index as well: <ng-template ngFor let-xb [ngForOf]="tempData" let-index="index">

ContentLicense: CC BY-SA 3.0

Body:
Not sure why my *ngFor loop is printing nothing out. I have the following code in an html file:

            Name
            Email
            Company
            Status

        <ng-template *ngFor="let xb of tempData">

                {{ xb.name }}
                {{ xb.email }}
                {{ xb.company }}
                {{ xb.status }}

        </ng-template>

Then, in my simple component I have the following:

import { Component }        from '@angular/core';

@Component({
    selector: 'my-profile-exhibitors',
    templateUrl: './profile-exhibitors.component.html',
    styleUrls: ['./profile-exhibitors.component.scss']
})
export class ProfileExhibitorsComponent {
    public tempData: any = [
        {
            'name': 'name1',
            'email': 'email1@gmail',
            'company': 'company',
            'status': 'Complete'
        },
        {
            'name': 'name2',
            'email': 'email2@gmail',
            'company': 'company',
            'status': 'Incomplete'
        }
    ];
    constructor() {}
}

When I run this code, I get zero output. Even weirder is that when I select the element using debug tools I see this:

Looks like it correctly recognizes my object, but then outputs nothing.


问:
How to update in one to one relation in laravel?
In my user model, I have the following code

```<code>public function profile()
{
    return $this->hasOne(UserProfile::class);
}
</code>```

In profile model,

```<code>public function user()
{
   return $this->belongsTo(User::class);
}
</code>```

The create method is working, But when I try to update the profile with following code, It is creating a new profile and doesn’t update the profile information.

```<code>$profile = new UserProfile();
$profile->dob = '1999-03-20';
$profile->bio = 'A professional programmer.';
$profile->facebook = 'http://facebook.com/test/1';
$profile->github = 'http://github.com/test/1';
$profile->twitter = 'http://twitter.com/test/1';

$user = User::find($userId);
$res = $user->profile()->save($profile);
</code>```

What is the correct method to update in One to One Relationship ?

答:
you are using save method to save new record. use update query </p>

```<code>//controller
$userObj=new User();
if(!empty($userId) && $userId!=null){
$userObj->updateByUserId($userId,[
'dob' = '1999-03-20';
'bio' = 'A professional programmer.';
'facebook' = 'http://facebook.com/test/1';
'github' = 'http://github.com/test/1';
'twitter' = 'http://twitter.com/test/1';
]);
}

//model
function updateByUserId($userId,$updateArray){
return $this->where('user_id',$userId)->update($updateArray);
}
</code>```

Body:
In my user model, I have the following code

public function profile()
{
    return $this->hasOne(UserProfile::class);
}

In profile model,

public function user()
{
   return $this->belongsTo(User::class);
}

The create method is working, But when I try to update the profile with following code, It is creating a new profile and doesn’t update the profile information.

$profile = new UserProfile();
$profile->dob = '1999-03-20';
$profile->bio = 'A professional programmer.';
$profile->facebook = 'http://facebook.com/test/1';
$profile->github = 'http://github.com/test/1';
$profile->twitter = 'http://twitter.com/test/1';

$user = User::find($userId);
$res = $user->profile()->save($profile);

What is the correct method to update in One to One Relationship ?

Body:
you are using save method to save new record. use update query

//controller
$userObj=new User();
if(!empty($userId) && $userId!=null){
$userObj->updateByUserId($userId,[
'dob' = '1999-03-20';
'bio' = 'A professional programmer.';
'facebook' = 'http://facebook.com/test/1';
'github' = 'http://github.com/test/1';
'twitter' = 'http://twitter.com/test/1';
]);
}

//model
function updateByUserId($userId,$updateArray){
return $this->where('user_id',$userId)->update($updateArray);
}


问:
MSSQL to POSTGRES conversion
Anyone can help me with the following query from mssql to postgres?

```<code>DateAdd(Week,-(doc.[DelaiLivraisonNum]),Convert(date,sas.DateFin)) as IdDate
</code>```

where DelaiLivraisonNum and DateFin are columns

Thanks

答:
I always struggle with the SQL Server syntax, but I think this would be the equivalent (it's hard to tell as you did not explain what your code does):

```<code>datefin::date - make_interval(weeks => delailivraisonnum)
</code>```

This assumes that datefin can be cast to a date (e.g. because it's a timestamp)  and delailivraisonnum is an integer.

Title: MSSQL to POSTGRES conversion

Body:
Anyone can help me with the following query from mssql to postgres?

DateAdd(Week,-(doc.[DelaiLivraisonNum]),Convert(date,sas.DateFin)) as IdDate

where DelaiLivraisonNum and DateFin are columns

Thanks

Body:
I always struggle with the SQL Server syntax, but I think this would be the equivalent (it's hard to tell as you did not explain what your code does):

datefin::date - make_interval(weeks => delailivraisonnum)

This assumes that datefin can be cast to a date (e.g. because it's a timestamp)  and delailivraisonnum is an integer.


问:
How to pass a string to a child view?
I want to pass the text in the textBox to the child view and create a scrollable Button there. As for the output status, we hope that 'a ~ c' are arranged vertically and that each is a button.

struct ContentView: View {
  var textBox = ["a","b","c"]
  var body: some View {
    VStack {
      ScrollView(.vertical, showsIndicators: false) {
        ForEach(0..<textBox.count) { number in
          ScrollText(text: self.textBox[number].lowercased())
        }
      }
    }
  }
}

struct ScrollText: View {
  @Binding  var text: String
  @State private var flag: Bool = false

  var body: some View {
    Button(action: {
      self.flag.toggle()
    }) {
      Text(text)
    }
  }
}
```

答:
If you're going to keep ScrollText untouched the here is possible modifications in ContentView which uses it

```<code>struct ContentView: View {
  @State private var textBox = ["a","b","c"] // < make State, so modifiable
  var body: some View {
    VStack {
      ScrollView(.vertical, showsIndicators: false) {
        ForEach(0..<textBox.count) { number in
          ScrollText(text: self.$textBox[number]) // < pass Binding as intended
        }
      }
    }
  }
}
</code>```

Title: How to pass a string to a child view?

Body:
If you're going to keep ScrollText untouched the here is possible modifications in ContentView which uses it

struct ContentView: View {
  @State private var textBox = ["a","b","c"] // < make State, so modifiable
  var body: some View {
    VStack {
      ScrollView(.vertical, showsIndicators: false) {
        ForEach(0..<textBox.count) { number in
          ScrollText(text: self.$textBox[number]) // < pass Binding as intended
        }
      }
    }
  }
}


问:
Trying to come up with Regex Expression
I am trying to parse this string: *(!((stunned)||dead))

Currently have

```<code>// ["*", "!", "stunned", "||dead"]
string.match(/[^()]+/g)
</code>```

Trying to get
["*", "!", "stunned", "||", "dead"]

Ideally in a way that would also separate it regarless of placement "||dead" or "dead||"

while support ||, &&, ==

答:
Perhaps you want to either match word characters, or non-word characters which are not parentheses:

const str = '*(!((stunned)||dead))';
console.log(str.match(/\w+|[^()\w]+/g));```

Title: Trying to come up with Regex Expression

Body:
I am trying to parse this string: *(!((stunned)||dead))

Currently have

// ["*", "!", "stunned", "||dead"]
string.match(/[^()]+/g)

Trying to get
["*", "!", "stunned", "||", "dead"]

Ideally in a way that would also separate it regarless of placement "||dead" or "dead||"

while support ||, &&, ==


问:
Rewriting my wordpress urls to become legacy urls
For a valid reason, I need to rewrite all the urls of my wordpress 'pages' to work as legacy urls.

So for example, when someone enters

www.mysite.com/contact_us I want to serve up the page thats sitting on my wordpress as `/contact-us/ but keep the url intact as contact_us

Currently my wordpress permalinks have been set to custom structure, which gives me the following in my .htaccess:

```<code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
</code>```

Can someone please show me how to add in a rule to rewrite the above. I have loads of urls to do but an example will be a huge help here. Thanks.

I've tried adding

ReWriteRule ^contact_us$ /contact-us/, but i just get a 404 on the /contact_us url.

答:
Ok I've sussed it: I have just rewritten it to the raw page url. I found the raw url by either turning off permalink rewriting, or by hovering over the view anchor for the specific page, in order to obtain the correct page_id value.</p>

```<code>RewriteRule ^contact_us/$ /?page_id=101 [L]
RewriteRule ^apply_now/$ /?page_id=41 [L]
</code>```

Body:
For a valid reason, I need to rewrite all the urls of my wordpress 'pages' to work as legacy urls.

So for example, when someone enters

www.mysite.com/contact_us I want to serve up the page thats sitting on my wordpress as `/contact-us/ but keep the url intact as contact_us

Currently my wordpress permalinks have been set to custom structure, which gives me the following in my .htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Can someone please show me how to add in a rule to rewrite the above. I have loads of urls to do but an example will be a huge help here. Thanks.

I've tried adding

ReWriteRule ^contact_us$ /contact-us/, but i just get a 404 on the /contact_us url.

Body:
Ok I've sussed it: I have just rewritten it to the raw page url. I found the raw url by either turning off permalink rewriting, or by hovering over the view anchor for the specific page, in order to obtain the correct page_id value.

RewriteRule ^contact_us/$ /?page_id=101 [L]
RewriteRule ^apply_now/$ /?page_id=41 [L]


问:
jQuery load() function doesn't work
I am new to the world of JavaScript and I'm trying to use the function load() to insert another html file. It' a little bit hard to explain, here is the code:

```<code><script>
$(document).ready(function() {
        $('#main').click(
            function(){
                $('#news').load('today.html');
            }
        ); //end click
}); //end ready
</script>
</code>```

Can you help me? I'm not using a web server.
Thanks

答:
You can find error message in load(url,fnResponse) response is success or fail

also check this jquery-load-method

```<code>$(document).ready(function() {
        $('#main').click(
            function(){
                $('#news').load('today.html', function( response, status, xhr ) {
                    if ( status == "error" ) {
                        alert( "Sorry but there was an error: " + xhr.status + " " + xhr.statusText );
                    }
                });
            }
        ); //end click
}); //end ready
</code>```

Title: jQuery load() function doesn't work

Body:
I am new to the world of JavaScript and I'm trying to use the function load() to insert another html file. It' a little bit hard to explain, here is the code:

Can you help me? I'm not using a web server.
Thanks

Body:
You can find error message in load(url,fnResponse) response is success or fail

also check this jquery-load-method

$(document).ready(function() {
        $('#main').click(
            function(){
                $('#news').load('today.html', function( response, status, xhr ) {
                    if ( status == "error" ) {
                        alert( "Sorry but there was an error: " + xhr.status + " " + xhr.statusText );
                    }
                });
            }
        ); //end click
}); //end ready


问:
Heatmap correlation using values of column?
Suppose I have the following data of repeat observations for US states with some value of interest:

```<code>US_State Value
Alabama  1
Alabama  10
Alabama  9
Michigan 8
Michigan 9
Michigan 2
...
</code>```

How can I generate pairwise correlations for Value between all the US_State combinations? I've tried a few different things (pivot, groupby, and more), but I can't seem to wrap my head around the proper approach.

The ideal output would look like:

```<code>          Alabama   Michigan    ...
Alabama      1          0.5
Michigan     0.5        1
...
</code>```

答:
Pandas DataFrame has a built-in correlation matrix function. You will somehow need to get your data into a DataFrame (takes numpy objects, plain dict (shown), etc).

from pandas import DataFrame

data = {'AL': [1,10,9],
        'MI': [8,9,2],
        'CO': [11,5,17]
        }

df = DataFrame(data)

corrMatrix = df.corr()
print(corrMatrix)

# optional heatmap
import seaborn as sn
sn.heatmap(corrMatrix, annot=True, cmap='coolwarm')

```

```          AL        MI        CO
AL  1.000000 -0.285578 -0.101361
MI -0.285578  1.000000 -0.924473
CO -0.101361 -0.924473  1.000000
```

Body:
Suppose I have the following data of repeat observations for US states with some value of interest:

US_State Value
Alabama  1
Alabama  10
Alabama  9
Michigan 8
Michigan 9
Michigan 2
...

How can I generate pairwise correlations for Value between all the US_State combinations? I've tried a few different things (pivot, groupby, and more), but I can't seem to wrap my head around the proper approach.

The ideal output would look like:

          Alabama   Michigan    ...
Alabama      1          0.5
Michigan     0.5        1
...

Body:
Pandas DataFrame has a built-in correlation matrix function. You will somehow need to get your data into a DataFrame (takes numpy objects, plain dict (shown), etc).

from pandas import DataFrame

data = {'AL': [1,10,9],
        'MI': [8,9,2],
        'CO': [11,5,17]
        }

df = DataFrame(data)

corrMatrix = df.corr()
print(corrMatrix)

# optional heatmap
import seaborn as sn
sn.heatmap(corrMatrix, annot=True, cmap='coolwarm')

          AL        MI        CO
AL  1.000000 -0.285578 -0.101361
MI -0.285578  1.000000 -0.924473
CO -0.101361 -0.924473  1.000000


问:
Compare and Count Variable Dates?
Using the given statement below I am Receiving the Value of Course end date which is in varchar and coming from MySQL I tried to convert this to date format in $ced & $newformat...all goes fine but when I am trying to compare course end date with the current date it's not comparing... it's only comparing the date and not comparing with year and month

```<code> $enddate = $get_students_row['course_end_date'];
 $ced = strtotime("$enddate");
 $newformat = date('d/m/Y',$ced);
 $currentdate = date('d/m/Y');
</code>```

The function is if $newformat is less than and eqals to current date then field become red

```<code><tr <?php if(($newformat <= $currentdate)): ?> style="color:red;" <?php endif; ?>>
</code>```

But its not working as excepted its make row red but its only comapring with current date not with month and year....Also i was looking for to get Total count of $newformat.

My Code

```<code>                <tr <?php if(($ced <= time())): ?> style="color:red;" <?php endif; ?>>

                   <td><?php  echo $students_rollno_class;?></td>
                   <td><?php  echo $students_admission_no;?> </td>
                   <td><?php  echo $students_firstname;?></td>
                   <td><?php  echo $students_contact;?></td>
                   <td><?php  echo $students_reference_no;?></td>
                   <td><?php  echo date('d/m/Y', strtotime($students_date));?></td>
                   <td><?php  echo $newformat;?></td>

               </tr><?php
                    }
                   ?>
</code>```

答:
$('#timeTable tr td').each(function () {
    var dtTd = new Date($(this).html());
    var dtNew = new Date();
    // 15 minutes is 900000 milliseconds

    if (dtTd.getTime() - dtNew.getTime() < 900000 && dtNew < dtTd) {
        $(this).parent('tr').addClass('min15');
    } else {
        if (dtNew > dtTd) {
            $(this).parent('tr').addClass('old');
        }
    }
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.old {
    background-color: red;
}</code>```

            02/07/2015 23:15

            03/09/2015 11:16

            18/02/2020 11:30

```

Title: Compare and Count Variable Dates?

Body:
Using the given statement below I am Receiving the Value of Course end date which is in varchar and coming from MySQL I tried to convert this to date format in $ced & $newformat...all goes fine but when I am trying to compare course end date with the current date it's not comparing... it's only comparing the date and not comparing with year and month

 $enddate = $get_students_row['course_end_date'];
 $ced = strtotime("$enddate");
 $newformat = date('d/m/Y',$ced);
 $currentdate = date('d/m/Y');

The function is if $newformat is less than and eqals to current date then field become red

<tr <?php if(($newformat <= $currentdate)): ?> style="color:red;" <?php endif; ?>>

But its not working as excepted its make row red but its only comapring with current date not with month and year....Also i was looking for to get Total count of $newformat.

My Code

                <tr <?php if(($ced <= time())): ?> style="color:red;" <?php endif; ?>>

                   <?php  echo $students_rollno_class;?>
                   <?php  echo $students_admission_no;?>
                   <?php  echo $students_firstname;?>
                   <?php  echo $students_contact;?>
                   <?php  echo $students_reference_no;?>
                   <?php  echo date('d/m/Y', strtotime($students_date));?>
                   <?php  echo $newformat;?>

<?php
                    }
                   ?>

Body:
$('#timeTable tr td').each(function () {
    var dtTd = new Date($(this).html());
    var dtNew = new Date();
    // 15 minutes is 900000 milliseconds

    if (dtTd.getTime() - dtNew.getTime() < 900000 && dtNew < dtTd) {
        $(this).parent('tr').addClass('min15');
    } else {
        if (dtNew > dtTd) {
            $(this).parent('tr').addClass('old');
        }
    }
});

.old {
    background-color: red;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<table id="timeTable">
    <tbody>
        <tr>
            <td>02/07/2015 23:15</td>
        </tr>
        <tr>
            <td>03/09/2015 11:16</td>
        </tr>
        <tr>
            <td>18/02/2020 11:30</td>
        </tr>
    </tbody>
</table>


问:
SQL DimCalendar dynamic fiscal week for calendar 5-4-4
My aims is to create a 5-4-4 calendar where my Accounting starting period = '2019-04-01' and ending period = '2020-03-31'
 My Fiscal Week should start from Week 1 to Week 52.
 Below is my SQL query which display my accounting calendar

```<code>DECLARE @START_DATE DATE
DECLARE @END_DATE DATE
DECLARE @COUNTER INT

SET @START_DATE = '2019-04-01'
SET @END_DATE = '2020-03-31'
SET @COUNTER = 1

DECLARE @TABLE TABLE(
  CALENDAR_DATE DATE,
  WEEK_NUM INTEGER,
  START_WEEK DATE,
  END_WEEK DATE
)

WHILE @START_DATE <= @END_DATE
BEGIN

SET DATEFIRST 4

INSERT INTO @TABLE (CALENDAR_DATE,START_WEEK,END_WEEK)

SELECT
 @START_DATE,
 DATEADD(dd, 0 - (@@DATEFIRST + 5 + DATEPART(dw, @START_DATE)) % 7, @START_DATE),
 DATEADD(dd, 6 - (@@DATEFIRST + 5 + DATEPART(dw, @START_DATE)) % 7, @START_DATE) Sunday

SET @START_DATE = DATEADD(day, 1, @START_DATE)
SET @COUNTER = @COUNTER + 1

END

SELECT DISTINCT
  START_WEEK,
  END_WEEK,
  CASE
    WHEN START_WEEK = '2019-04-01' AND END_WEEK = '2019-04-07' THEN 'WEEK 1'
    WHEN START_WEEK = '2019-04-08' AND END_WEEK = '2019-04-14' THEN 'WEEK 2'
    WHEN START_WEEK = '2019-04-15' AND END_WEEK = '2019-04-21' THEN 'WEEK 3'
    WHEN START_WEEK = '2019-04-22' AND END_WEEK = '2019-04-28' THEN 'WEEK 4'
    WHEN START_WEEK = '2019-04-29' AND END_WEEK = '2019-05-05' THEN 'WEEK 5'
    WHEN START_WEEK = '2019-05-06' AND END_WEEK = '2019-05-12' THEN 'WEEK 6'
    WHEN START_WEEK = '2019-05-13' AND END_WEEK = '2019-05-19' THEN 'WEEK 7'
    WHEN START_WEEK = '2019-05-20' AND END_WEEK = '2019-05-26' THEN 'WEEK 8'
    WHEN START_WEEK = '2019-05-27' AND END_WEEK = '2019-06-02' THEN 'WEEK 9'
    WHEN START_WEEK = '2019-06-03' AND END_WEEK = '2019-06-09' THEN 'WEEK 10'
    WHEN START_WEEK = '2019-06-10' AND END_WEEK = '2019-06-16' THEN 'WEEK 11'
    WHEN START_WEEK = '2019-06-17' AND END_WEEK = '2019-06-23' THEN 'WEEK 12'
    WHEN START_WEEK = '2019-06-24' AND END_WEEK = '2019-06-30' THEN 'WEEK 13'
    WHEN START_WEEK = '2019-07-01' AND END_WEEK = '2019-07-07' THEN 'WEEK 14'
    WHEN START_WEEK = '2019-07-08' AND END_WEEK = '2019-07-14' THEN 'WEEK 15'
    WHEN START_WEEK = '2019-07-15' AND END_WEEK = '2019-07-21' THEN 'WEEK 16'
    WHEN START_WEEK = '2019-07-22' AND END_WEEK = '2019-07-28' THEN 'WEEK 17'
    WHEN START_WEEK = '2019-07-29' AND END_WEEK = '2019-08-04' THEN 'WEEK 18'
    WHEN START_WEEK = '2019-08-05' AND END_WEEK = '2019-08-11' THEN 'WEEK 19'
    WHEN START_WEEK = '2019-08-12' AND END_WEEK = '2019-08-18' THEN 'WEEK 20'
    WHEN START_WEEK = '2019-08-19' AND END_WEEK = '2019-08-25' THEN 'WEEK 21'
    WHEN START_WEEK = '2019-08-26' AND END_WEEK = '2019-09-01' THEN 'WEEK 22'
    WHEN START_WEEK = '2019-09-02' AND END_WEEK = '2019-09-08' THEN 'WEEK 23'
    WHEN START_WEEK = '2019-09-09' AND END_WEEK = '2019-09-15' THEN 'WEEK 24'
    WHEN START_WEEK = '2019-09-16' AND END_WEEK = '2019-09-22' THEN 'WEEK 25'
    WHEN START_WEEK = '2019-09-23' AND END_WEEK = '2019-09-29' THEN 'WEEK 26'
    WHEN START_WEEK = '2019-09-30' AND END_WEEK = '2019-10-06' THEN 'WEEK 27'
    WHEN START_WEEK = '2019-10-07' AND END_WEEK = '2019-10-13' THEN 'WEEK 28'
    WHEN START_WEEK = '2019-10-14' AND END_WEEK = '2019-10-20' THEN 'WEEK 29'
    WHEN START_WEEK = '2019-10-21' AND END_WEEK = '2019-10-27' THEN 'WEEK 30'
    WHEN START_WEEK = '2019-10-28' AND END_WEEK = '2019-11-03' THEN 'WEEK 31'
    WHEN START_WEEK = '2019-11-04' AND END_WEEK = '2019-11-10' THEN 'WEEK 32'
    WHEN START_WEEK = '2019-11-11' AND END_WEEK = '2019-11-17' THEN 'WEEK 33'
    WHEN START_WEEK = '2019-11-18' AND END_WEEK = '2019-11-24' THEN 'WEEK 34'
    WHEN START_WEEK = '2019-11-25' AND END_WEEK = '2019-12-01' THEN 'WEEK 35'
    WHEN START_WEEK = '2019-12-02' AND END_WEEK = '2019-12-08' THEN 'WEEK 36'
    WHEN START_WEEK = '2019-12-09' AND END_WEEK = '2019-12-15' THEN 'WEEK 37'
    WHEN START_WEEK = '2019-12-16' AND END_WEEK = '2019-12-22' THEN 'WEEK 38'
    WHEN START_WEEK = '2019-12-23' AND END_WEEK = '2019-12-29' THEN 'WEEK 39'
    WHEN START_WEEK = '2019-12-30' AND END_WEEK = '2020-01-05' THEN 'WEEK 40'
    WHEN START_WEEK = '2020-01-06' AND END_WEEK = '2020-01-12' THEN 'WEEK 41'
    WHEN START_WEEK = '2020-01-13' AND END_WEEK = '2020-01-19' THEN 'WEEK 42'
    WHEN START_WEEK = '2020-01-20' AND END_WEEK = '2020-01-26' THEN 'WEEK 43'
    WHEN START_WEEK = '2020-01-27' AND END_WEEK = '2020-02-02' THEN 'WEEK 44'
    WHEN START_WEEK = '2020-02-03' AND END_WEEK = '2020-02-09' THEN 'WEEK 45'
    WHEN START_WEEK = '2020-02-10' AND END_WEEK = '2020-02-16' THEN 'WEEK 46'
    WHEN START_WEEK = '2020-02-17' AND END_WEEK = '2020-02-23' THEN 'WEEK 47'
    WHEN START_WEEK = '2020-02-24' AND END_WEEK = '2020-03-01' THEN 'WEEK 48'
    WHEN START_WEEK = '2020-03-02' AND END_WEEK = '2020-03-08' THEN 'WEEK 49'
    WHEN START_WEEK = '2020-03-09' AND END_WEEK = '2020-03-15' THEN 'WEEK 50'
    WHEN START_WEEK = '2020-03-16' AND END_WEEK = '2020-03-22' THEN 'WEEK 51'
    WHEN START_WEEK = '2020-03-23' AND END_WEEK = '2020-03-29' THEN 'WEEK 52'
  END AS FY_WEEK
 FROM @TABLE
 ORDER BY START_WEEK,END_WEEK;
</code>```

My problem is the Fiscal Week (FY_WEEK) column, I don't want to hard-code those START_WEEK and END_WEEK value.

I'm looking for a way where I can dynamically populate my fiscal week column instead of hardcoding values.

答:
This might help</p>

```<code>SELECT DISTINCT
  START_WEEK,
  END_WEEK,
    DATEDIFF(WEEK,
        CONVERT(VARCHAR(4), CASE WHEN DATEPART(MONTH, START_WEEK) BETWEEN 4 AND 12 THEN DATEPART(YEAR, START_WEEK) ELSE DATEPART(YEAR, START_WEEK)-1 END)+'0401',
        START_WEEK
    )+1 AS 'FY_WEEK'
 FROM @TABLE
 ORDER BY START_WEEK,END_WEEK;
</code>```

Body:
My aims is to create a 5-4-4 calendar where my Accounting starting period = '2019-04-01' and ending period = '2020-03-31'
 My Fiscal Week should start from Week 1 to Week 52.
 Below is my SQL query which display my accounting calendar

DECLARE @START_DATE DATE
DECLARE @END_DATE DATE
DECLARE @COUNTER INT

SET @START_DATE = '2019-04-01'
SET @END_DATE = '2020-03-31'
SET @COUNTER = 1

DECLARE @TABLE TABLE(
  CALENDAR_DATE DATE,
  WEEK_NUM INTEGER,
  START_WEEK DATE,
  END_WEEK DATE
)

WHILE @START_DATE <= @END_DATE
BEGIN

SET DATEFIRST 4

INSERT INTO @TABLE (CALENDAR_DATE,START_WEEK,END_WEEK)

SELECT
 @START_DATE,
 DATEADD(dd, 0 - (@@DATEFIRST + 5 + DATEPART(dw, @START_DATE)) % 7, @START_DATE),
 DATEADD(dd, 6 - (@@DATEFIRST + 5 + DATEPART(dw, @START_DATE)) % 7, @START_DATE) Sunday

SET @START_DATE = DATEADD(day, 1, @START_DATE)
SET @COUNTER = @COUNTER + 1

END

SELECT DISTINCT
  START_WEEK,
  END_WEEK,
  CASE
    WHEN START_WEEK = '2019-04-01' AND END_WEEK = '2019-04-07' THEN 'WEEK 1'
    WHEN START_WEEK = '2019-04-08' AND END_WEEK = '2019-04-14' THEN 'WEEK 2'
    WHEN START_WEEK = '2019-04-15' AND END_WEEK = '2019-04-21' THEN 'WEEK 3'
    WHEN START_WEEK = '2019-04-22' AND END_WEEK = '2019-04-28' THEN 'WEEK 4'
    WHEN START_WEEK = '2019-04-29' AND END_WEEK = '2019-05-05' THEN 'WEEK 5'
    WHEN START_WEEK = '2019-05-06' AND END_WEEK = '2019-05-12' THEN 'WEEK 6'
    WHEN START_WEEK = '2019-05-13' AND END_WEEK = '2019-05-19' THEN 'WEEK 7'
    WHEN START_WEEK = '2019-05-20' AND END_WEEK = '2019-05-26' THEN 'WEEK 8'
    WHEN START_WEEK = '2019-05-27' AND END_WEEK = '2019-06-02' THEN 'WEEK 9'
    WHEN START_WEEK = '2019-06-03' AND END_WEEK = '2019-06-09' THEN 'WEEK 10'
    WHEN START_WEEK = '2019-06-10' AND END_WEEK = '2019-06-16' THEN 'WEEK 11'
    WHEN START_WEEK = '2019-06-17' AND END_WEEK = '2019-06-23' THEN 'WEEK 12'
    WHEN START_WEEK = '2019-06-24' AND END_WEEK = '2019-06-30' THEN 'WEEK 13'
    WHEN START_WEEK = '2019-07-01' AND END_WEEK = '2019-07-07' THEN 'WEEK 14'
    WHEN START_WEEK = '2019-07-08' AND END_WEEK = '2019-07-14' THEN 'WEEK 15'
    WHEN START_WEEK = '2019-07-15' AND END_WEEK = '2019-07-21' THEN 'WEEK 16'
    WHEN START_WEEK = '2019-07-22' AND END_WEEK = '2019-07-28' THEN 'WEEK 17'
    WHEN START_WEEK = '2019-07-29' AND END_WEEK = '2019-08-04' THEN 'WEEK 18'
    WHEN START_WEEK = '2019-08-05' AND END_WEEK = '2019-08-11' THEN 'WEEK 19'
    WHEN START_WEEK = '2019-08-12' AND END_WEEK = '2019-08-18' THEN 'WEEK 20'
    WHEN START_WEEK = '2019-08-19' AND END_WEEK = '2019-08-25' THEN 'WEEK 21'
    WHEN START_WEEK = '2019-08-26' AND END_WEEK = '2019-09-01' THEN 'WEEK 22'
    WHEN START_WEEK = '2019-09-02' AND END_WEEK = '2019-09-08' THEN 'WEEK 23'
    WHEN START_WEEK = '2019-09-09' AND END_WEEK = '2019-09-15' THEN 'WEEK 24'
    WHEN START_WEEK = '2019-09-16' AND END_WEEK = '2019-09-22' THEN 'WEEK 25'
    WHEN START_WEEK = '2019-09-23' AND END_WEEK = '2019-09-29' THEN 'WEEK 26'
    WHEN START_WEEK = '2019-09-30' AND END_WEEK = '2019-10-06' THEN 'WEEK 27'
    WHEN START_WEEK = '2019-10-07' AND END_WEEK = '2019-10-13' THEN 'WEEK 28'
    WHEN START_WEEK = '2019-10-14' AND END_WEEK = '2019-10-20' THEN 'WEEK 29'
    WHEN START_WEEK = '2019-10-21' AND END_WEEK = '2019-10-27' THEN 'WEEK 30'
    WHEN START_WEEK = '2019-10-28' AND END_WEEK = '2019-11-03' THEN 'WEEK 31'
    WHEN START_WEEK = '2019-11-04' AND END_WEEK = '2019-11-10' THEN 'WEEK 32'
    WHEN START_WEEK = '2019-11-11' AND END_WEEK = '2019-11-17' THEN 'WEEK 33'
    WHEN START_WEEK = '2019-11-18' AND END_WEEK = '2019-11-24' THEN 'WEEK 34'
    WHEN START_WEEK = '2019-11-25' AND END_WEEK = '2019-12-01' THEN 'WEEK 35'
    WHEN START_WEEK = '2019-12-02' AND END_WEEK = '2019-12-08' THEN 'WEEK 36'
    WHEN START_WEEK = '2019-12-09' AND END_WEEK = '2019-12-15' THEN 'WEEK 37'
    WHEN START_WEEK = '2019-12-16' AND END_WEEK = '2019-12-22' THEN 'WEEK 38'
    WHEN START_WEEK = '2019-12-23' AND END_WEEK = '2019-12-29' THEN 'WEEK 39'
    WHEN START_WEEK = '2019-12-30' AND END_WEEK = '2020-01-05' THEN 'WEEK 40'
    WHEN START_WEEK = '2020-01-06' AND END_WEEK = '2020-01-12' THEN 'WEEK 41'
    WHEN START_WEEK = '2020-01-13' AND END_WEEK = '2020-01-19' THEN 'WEEK 42'
    WHEN START_WEEK = '2020-01-20' AND END_WEEK = '2020-01-26' THEN 'WEEK 43'
    WHEN START_WEEK = '2020-01-27' AND END_WEEK = '2020-02-02' THEN 'WEEK 44'
    WHEN START_WEEK = '2020-02-03' AND END_WEEK = '2020-02-09' THEN 'WEEK 45'
    WHEN START_WEEK = '2020-02-10' AND END_WEEK = '2020-02-16' THEN 'WEEK 46'
    WHEN START_WEEK = '2020-02-17' AND END_WEEK = '2020-02-23' THEN 'WEEK 47'
    WHEN START_WEEK = '2020-02-24' AND END_WEEK = '2020-03-01' THEN 'WEEK 48'
    WHEN START_WEEK = '2020-03-02' AND END_WEEK = '2020-03-08' THEN 'WEEK 49'
    WHEN START_WEEK = '2020-03-09' AND END_WEEK = '2020-03-15' THEN 'WEEK 50'
    WHEN START_WEEK = '2020-03-16' AND END_WEEK = '2020-03-22' THEN 'WEEK 51'
    WHEN START_WEEK = '2020-03-23' AND END_WEEK = '2020-03-29' THEN 'WEEK 52'
  END AS FY_WEEK
 FROM @TABLE
 ORDER BY START_WEEK,END_WEEK;

My problem is the Fiscal Week (FY_WEEK) column, I don't want to hard-code those START_WEEK and END_WEEK value.

I'm looking for a way where I can dynamically populate my fiscal week column instead of hardcoding values.

Body:
This might help

SELECT DISTINCT
  START_WEEK,
  END_WEEK,
    DATEDIFF(WEEK,
        CONVERT(VARCHAR(4), CASE WHEN DATEPART(MONTH, START_WEEK) BETWEEN 4 AND 12 THEN DATEPART(YEAR, START_WEEK) ELSE DATEPART(YEAR, START_WEEK)-1 END)+'0401',
        START_WEEK
    )+1 AS 'FY_WEEK'
 FROM @TABLE
 ORDER BY START_WEEK,END_WEEK;


问:
Duplicate Function Implementation
I have one file, app.ts under my scripts folder, that gets copied to wwwroot/scripts by a gulp task. After the gulp task runs, I now also have a wwwroot/scripts/app.ts file, in which the sole function is red-underlined as duplicate. Is this normal, or is my gulp task, below, declared incorrectly?

```<code>var paths = {
    scripts: ["scripts/**/*.js", "scripts/**/*.ts", "scripts/**/*.map"]
};

gulp.task("default", function() {
    gulp.src(paths.scripts).pipe(gulp.dest("wwwroot/scripts"));
});
</code>```

I see the raw app.ts file, from the root scripts folder also gets built into *.js and *.js.map files. Could this have something to do with the 'false positive' duplicate function?

答:
Don't copy the .ts files. You only need the compiled .js files in the scripts directory (unless you are doing something unusual with TypeScript source from there).

Then in your tsconfig.json file, add an exclude directive to exclude wwwroot/scripts/**/* in your IDE.

Title: Duplicate Function Implementation

Body:
I have one file, app.ts under my scripts folder, that gets copied to wwwroot/scripts by a gulp task. After the gulp task runs, I now also have a wwwroot/scripts/app.ts file, in which the sole function is red-underlined as duplicate. Is this normal, or is my gulp task, below, declared incorrectly?

var paths = {
    scripts: ["scripts/**/*.js", "scripts/**/*.ts", "scripts/**/*.map"]
};

gulp.task("default", function() {
    gulp.src(paths.scripts).pipe(gulp.dest("wwwroot/scripts"));
});

I see the raw app.ts file, from the root scripts folder also gets built into *.js and *.js.map files. Could this have something to do with the 'false positive' duplicate function?


问:
In ANDROID, How to get a current position and tracking in map using GPS without giving any location in a program?
I am new to android, can anyone help me for my question....
How to get a current position and tracking in map using GPS without giving any location in a program?????</p>

答:
Try ;

```<code>          String m_BestProvider;
          LocationManager m_LocationManager;
          LocationListener m_LocationListener = null;
          Location m_Location = null;

          m_LocationManager = (LocationManager) m_Context.getSystemService(Context.LOCATION_SERVICE);

          Criteria c = new Criteria();
          c.setAccuracy(Criteria.ACCURACY_COARSE);
          c.setAltitudeRequired(false);
          c.setBearingRequired(false);
          c.setSpeedRequired(false);
          c.setCostAllowed(true);
          c.setPowerRequirement(Criteria.POWER_HIGH);

                    m_BestProvider = m_LocationManager.getBestProvider(c, false);

                    // Define a listener that responds to location updates
                    m_LocationListener = new LocationListener() {
                        public void onLocationChanged(Location location) {
                          // Called when a new location is found by the network location provider.
                        }

                        public void onStatusChanged(String provider, int status, Bundle extras) {}

                        public void onProviderEnabled(String provider) {}

                        public void onProviderDisabled(String provider) {}
                      };

                    m_LocationManager.requestLocationUpdates(m_BestProvider, 0, 0, m_LocationListener);
                    m_Location = m_LocationManager.getLastKnownLocation(m_BestProvider);
                    Systme.out.println(m_Location.getLatitude() "," +m_Location.getLongitude());
</code>```

Add in AndriodManifest.xml:

```<code><uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</code>```

Body:
Try ;

          String m_BestProvider;
          LocationManager m_LocationManager;
          LocationListener m_LocationListener = null;
          Location m_Location = null;

          m_LocationManager = (LocationManager) m_Context.getSystemService(Context.LOCATION_SERVICE);

          Criteria c = new Criteria();
          c.setAccuracy(Criteria.ACCURACY_COARSE);
          c.setAltitudeRequired(false);
          c.setBearingRequired(false);
          c.setSpeedRequired(false);
          c.setCostAllowed(true);
          c.setPowerRequirement(Criteria.POWER_HIGH);

                    m_BestProvider = m_LocationManager.getBestProvider(c, false);

                    // Define a listener that responds to location updates
                    m_LocationListener = new LocationListener() {
                        public void onLocationChanged(Location location) {
                          // Called when a new location is found by the network location provider.
                        }

                        public void onStatusChanged(String provider, int status, Bundle extras) {}

                        public void onProviderEnabled(String provider) {}

                        public void onProviderDisabled(String provider) {}
                      };

                    m_LocationManager.requestLocationUpdates(m_BestProvider, 0, 0, m_LocationListener);
                    m_Location = m_LocationManager.getLastKnownLocation(m_BestProvider);
                    Systme.out.println(m_Location.getLatitude() "," +m_Location.getLongitude());

Add in AndriodManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>


问:
Xamarin Forms view coordinates and Android view coordinates
PREMISE: This Answer does NOT answer my question, here I ask HOW to solve this "conflict problem".

I noticed that coordinates of a view in Xamarin Forms are different from the coordinates of the same view taken in Android, something like view.X=150 (in Xamarin Forms) correspond to view.GetX()=900 (in Xamarin Android). This causes me a lot of problem, because I am trying to implement drag and drop using android custom renderer, in which I have to know the position of the drop zone (using myDestinationRect.Contains(myTouchX,myTouchY)), but since the position that I have in Forms is different from the position needed in the Android custom renderer, that become impossible for me. Is there a way to like "convert" forms coordinates to android coordinates? Or are there any other solutions?

PS: in iOS everything works fine, it seems that Forms and iOS use same coordinates system.

答:
Try to get the Device Density first,then *density to convert to android coordinates.

```<code>var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
var density = mainDisplayInfo.Density;
int XForms = view.X;
int XAndroid = XForms*density; //convert to android coordinates.
</code>```

Body:
Try to get the Device Density first,then *density to convert to android coordinates.

var mainDisplayInfo = DeviceDisplay.MainDisplayInfo;
var density = mainDisplayInfo.Density;
int XForms = view.X;
int XAndroid = XForms*density; //convert to android coordinates.


问:
How do I properly nest this If statement
I'm capturing user input but restricting them between 1-100. I'm having some difficulty nesting this if statement correctly.
Goal:
user can input any amount between 1-100
if not, it sets automatically to 0.
I print the results at the end</p>

```<code>    // if statement to restrict use to 1-100
    hatNumber = in.readInt("How many beaver hats would you like?: \n");
    if (hatNumber <= 0 && hatNumber > 100) {
        System.out.println("Hats = " + hatNumber);
    } else {
        hatNumber = 0;
    }
    photoNumber = in.readInt("How many photographs would you like?: \n");
    if (photoNumber <= 0 && photoNumber > 100) {
        System.out.println("Photographs = " + photoNumber);
    } else {
        photoNumber = 0;

        jarNumber = in.readInt("How many Jars of maple syrup?: \n");

    if (jarNumber <= 0 && jarNumber > 100) {
            System.out.println("Jars = " + jarNumber);

        } else {
            jarNumber = 0;
            {

                System.out.println("Hats = " + hatNumber);
                System.out.println("Photographs = " + photoNumber);
                System.out.println("Jars = " + jarNumber);
</code>```

答:
```<code> if (hatNumber <= 0 && hatNumber > 100)
</code>```

This condition can never be true in any case. you shold use the following condition

```<code> if (hatNumber > 0 && hatNumber < 100) {
    System.out.println("Hats = " + hatNumber);
 }
</code>```

Body:
I'm capturing user input but restricting them between 1-100. I'm having some difficulty nesting this if statement correctly.
Goal:
user can input any amount between 1-100
if not, it sets automatically to 0.
I print the results at the end

    // if statement to restrict use to 1-100
    hatNumber = in.readInt("How many beaver hats would you like?: \n");
    if (hatNumber <= 0 && hatNumber > 100) {
        System.out.println("Hats = " + hatNumber);
    } else {
        hatNumber = 0;
    }
    photoNumber = in.readInt("How many photographs would you like?: \n");
    if (photoNumber <= 0 && photoNumber > 100) {
        System.out.println("Photographs = " + photoNumber);
    } else {
        photoNumber = 0;

        jarNumber = in.readInt("How many Jars of maple syrup?: \n");

    if (jarNumber <= 0 && jarNumber > 100) {
            System.out.println("Jars = " + jarNumber);

        } else {
            jarNumber = 0;
            {

                System.out.println("Hats = " + hatNumber);
                System.out.println("Photographs = " + photoNumber);
                System.out.println("Jars = " + jarNumber);

Body:
 if (hatNumber <= 0 && hatNumber > 100)

This condition can never be true in any case. you shold use the following condition

 if (hatNumber > 0 && hatNumber < 100) {
    System.out.println("Hats = " + hatNumber);
 }


问:
Using SQL to exclude a word that comes after a phrase
This issue might be a bit too complicated for SQL to handle, but since I have pretty intermediate SQL skills perhaps someone more well-versed in SQL than me will know how to fix the below issue.

I am looking to isolate observations that mention a keyword that occur after a phrase. An example would be like below: For variable FREE_TEXT I want to isolate where the word orange is said AFTER the phrase Excluding This:

FREE_TEXT=
"Including This:

The best fruit is an apple

Excluding This:

The worst fruit is an orange"

Technically I could just do where FREE_TEXT not like '%orange%' but that is not what I am looking for. I am looking to specifically isolate for when a word is said AFTER the phrase Excluding This.

Anyone have ideas?

答:
This will find the word orange in the string after the phrase Excluding This

```<code>select  STRPOS(SUBSTRING(free_text
                         , position('Excluding This' in free_text)
                           + length('Excluding This'))
                         , 'orange')
from test
</code>```

I have used position function to find the position of the string Excluding This because I wanted to start my search after that string. The position function returned the position of the character E of the string Excluding Thisso I had to add length of that expresion to find the wanted position from where I start my search.

After I had my position from where I will start my search, and I had the keyword that I need to find it was easy to use string functions STRPOS and SUBSTRING to check if the string value in the column free_text contains word orange.

Here is a demo

Body:
This will find the word orange in the string after the phrase Excluding This

select  STRPOS(SUBSTRING(free_text
                         , position('Excluding This' in free_text)
                           + length('Excluding This'))
                         , 'orange')
from test

I have used position function to find the position of the string Excluding This because I wanted to start my search after that string. The position function returned the position of the character E of the string Excluding Thisso I had to add length of that expresion to find the wanted position from where I start my search.

After I had my position from where I will start my search, and I had the keyword that I need to find it was easy to use string functions STRPOS and SUBSTRING to check if the string value in the column free_text contains word orange.

Here is a demo


问:
How to validate solr query syntax using standard query parser
I am using solr 8.2 version. Here, I am passing the below queries in solr dashboard query screen. e.g

select * xyz
delete * xyz
xyz * abc.

Solr return all results with the above queries. I want to understand how solr is parsing it internally.
and returning all records?

Thanks!

答:
The essential tool for debugging search results is the “explain” mechanism of Solr which is triggered by adding &debug=true to search queries. This produces detail scoring information for each document.

The debug parameter can be specified multiple times and supports the following arguments:

debug=query: return debug information about the query only.

debug=timing: return debug information about how long the query took to process.

debug=results: return debug information about the score results (also known as "explain").

By default, score explanations are returned as large string values, using newlines and tab indenting for structure & readability, but an additional debug.explain.structured=true parameter may be specified to return this information as nested data structures native to the response format requested by wt.

debug=all: return all available debug information about the request request.

You could also use the analysis tool in solr. Go to the admin and click analysis.

There is Solr Query Debugger extension available for crome browser. This will help to modify, execute and explain solr queries.
Its available here : Solr Query Debugger


问:
Problem when querying the database
When I do:

```<code>channel = session.query(Channel).options(eagerload("items")).filter(Channel.title == title)
</code>```

I get this error:

```<code>TypeError: 'bool' object is not callable
</code>```

If I rid of options(eagerload("items")), it's working properly.

Any idea??

Thanks in advance!

答:
SQLAlchemy filtering works with operator overloading on column objects. You are, however, not referencing the column object, but the value property of the table. So instead of

```<code>Channel.title == title
</code>```

which is a 'bool' object, you need

```<code>Channel.c.title == title
</code>```

which yields a SLQAlchemy specific object.

ContentLicense: CC BY-SA 2.5

Title: Problem when querying the database

Body:
When I do:

channel = session.query(Channel).options(eagerload("items")).filter(Channel.title == title)

I get this error:

TypeError: 'bool' object is not callable

If I rid of options(eagerload("items")), it's working properly.

Any idea??

Thanks in advance!

Body:
SQLAlchemy filtering works with operator overloading on column objects. You are, however, not referencing the column object, but the value property of the table. So instead of

Channel.title == title

which is a 'bool' object, you need

Channel.c.title == title

which yields a SLQAlchemy specific object.


问:
How to dismiss flutter dismissable widget programmatically?
Is it possible to dismiss dismissable programmatically? Not by swipe, but by let's say button click.
 The only thing that comes in mind is imitating gesture event with a certain velocity, but this sounds horribly wrong.</p>

答:
How about considering an AnimatedList instead.

A scrolling container that animates items when they are inserted or removed.
  This widget is similar to one created by ListView.builder.


问:
How to update database record in Laravel
i use this rout ==> Route::put('update/{id}','testcontroller@update');

And i use this function

```<code>public function update(Request $request, $id)
   {

    $input=[
        'name' => $request->name,
        'email' => $request->email,
        'password' => $request->password,
    ];
    $update = DB::table('users')->where('id', $id)->update($input);
    if ($update) {
        dd('updated');
    }
    else{
        dd('error');

   }
}
</code>```

but i see a error.

答:
Try this

```<code>$this->validate($request, [
    'user_name' => 'required|max:255',
    'email' => 'required',
    'password' => 'required|min:8'
]);
    $user = User::findOrFail($id);
    $input = $request->all();
    $user->fill($input)->save();
</code>```

Or try this

```<code>$this->validate($request, [
    'user_name' => 'required|max:255',
    'email' => 'required',
    'password' => 'required|min:8'
]);
    $user = User::findOrFail($id);
    $user->user_name = $request->input('user_name');
    $user->email = $request->input('email');
    $user->password = $request->input('password');
    $user->save();
</code>```

Both are correct ways for update.

Body:
i use this rout ==> Route::put('update/{id}','testcontroller@update');

And i use this function

public function update(Request $request, $id)
   {

    $input=[
        'name' => $request->name,
        'email' => $request->email,
        'password' => $request->password,
    ];
    $update = DB::table('users')->where('id', $id)->update($input);
    if ($update) {
        dd('updated');
    }
    else{
        dd('error');

   }
}

but i see a error.

Body:
Try this

$this->validate($request, [
    'user_name' => 'required|max:255',
    'email' => 'required',
    'password' => 'required|min:8'
]);
    $user = User::findOrFail($id);
    $input = $request->all();
    $user->fill($input)->save();

Or try this

$this->validate($request, [
    'user_name' => 'required|max:255',
    'email' => 'required',
    'password' => 'required|min:8'
]);
    $user = User::findOrFail($id);
    $user->user_name = $request->input('user_name');
    $user->email = $request->input('email');
    $user->password = $request->input('password');
    $user->save();

Both are correct ways for update.


问:
Text lowercase after capitalization is possible?
My database give mixed font styles, for Example:

" Hi THis is TEST teXT "

I want to capitalization this type of fonts. I found a way, first using lowercase and then ::first-letter to be capitalized. This give the first letter only capital.

But I want capitalization in every first word, is there any way?

答:
div.c {
  text-transform: capitalize;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<body>
<h2>text-transform: capitalize:</h2>
<div class="c">Hi THis is TEST teXT</div>

</body>
</html></code>```

Try this.

Body:
div.c {
  text-transform: capitalize;
}

<html>
<body>
<h2>text-transform: capitalize:</h2>
<div class="c">Hi THis is TEST teXT</div>

</body>
</html>

Try this.


问:
handleClick in React
I have a MenuCard component which contains a handleClick which returns the names and images of the various menus. I also have a LikeButton component which has a counter and increments each time the button is pressed.

I am having problems trying to use this LikeButton in the MenuCard as every time I click the button, it goes to the selected menu's id page, which it should do if the user clicks on the card.

But how can I have it avoid that when I click LikeButton? I am just not sure where to call LikeButton in MenuCard.

MenuCard Component:

```<code>import React from 'react';

import Card from 'react-bootstrap/Card'

import LikeButton from "../components/LikeButton";

const MenuCard = props => {

    const handleClick = () => {
        props.view(props.info.id, "menus", 'DISPLAY_MENUS');
    };

    return (
        <Card onClick={handleClick} style={{ width: '18rem' }}>
            <Card.Body>
                <Card.Title>{props.info.name}<LikeButton /></Card.Title>
            </Card.Body>
            <Card.Img variant="bottom" style={{ height: '12rem' }} src={props.info.image} />
        </Card>
    )
}

export default MenuCard
</code>```

LikeButton Component:

```<code>import React, { Component } from 'react';

import Button from 'react-bootstrap/Button'

class LikeButton extends Component {
  state = {
      count: 0
    }

increment = () => {
      let newCount = this.state.count + 1
      this.setState({
        count: newCount
      })
    }

render() {
  return (
   <div>
     <button onClick={this.increment}>Likes: {this.state.count} </button>
   </div>
  )
}

}

export default LikeButton;
</code>```

答:
Use event.stopPropagation in your LikeButton component to prevent onClick event from bubbling up to MenuCard component:

<button
  onClick={e => {
    e.stopPropagation();
    this.increment();
  }
>
Likes: {this.state.count}
</button>
```

Title: handleClick in React

Body:
I have a MenuCard component which contains a handleClick which returns the names and images of the various menus. I also have a LikeButton component which has a counter and increments each time the button is pressed.

I am having problems trying to use this LikeButton in the MenuCard as every time I click the button, it goes to the selected menu's id page, which it should do if the user clicks on the card.

But how can I have it avoid that when I click LikeButton? I am just not sure where to call LikeButton in MenuCard.

MenuCard Component:

import React from 'react';

import Card from 'react-bootstrap/Card'

import LikeButton from "../components/LikeButton";

const MenuCard = props => {

    const handleClick = () => {
        props.view(props.info.id, "menus", 'DISPLAY_MENUS');
    };

    return (
        <Card onClick={handleClick} style={{ width: '18rem' }}>
            <Card.Body>
                <Card.Title>{props.info.name}<LikeButton /></Card.Title>
            </Card.Body>
            <Card.Img variant="bottom" style={{ height: '12rem' }} src={props.info.image} />
        </Card>
    )
}

export default MenuCard

LikeButton Component:

import React, { Component } from 'react';

import Button from 'react-bootstrap/Button'

class LikeButton extends Component {
  state = {
      count: 0
    }

increment = () => {
      let newCount = this.state.count + 1
      this.setState({
        count: newCount
      })
    }

render() {
  return (

     <button onClick={this.increment}>Likes: {this.state.count} </button>

  )
}

}

export default LikeButton;


答:
Try this:

```<code>UPDATE accounting_entries as ae
SET    name = 'C' + SubString(name, 1, Length(name) - 1))
       amount = amount * -1
       type = 'Credit'
WHERE  id =
         (SELECT MIN(id) FROM
            (SELECT * FROM accounting_entries) as temp
          GROUP BY name)
</code>```

The key is the subquery in the WHERE section that limits the updates to the lowest ID of each name value. The assumption is that the lower ID is the one that you will always want to update. If this is not correct, then update the subquery based on whatever rule you would use.

Edit: Update to subquery based on technique found here, due to limitation on mysql defined here.

This query gives a method for updating all records at once (as it seemed like this is what the OP was looking for. However, the most efficient way to do this would be to enumerate through all records in code (php, asp.net, etc), and through code-based methods update the rows that needed to change. This would eliminate the performance issues inherent with running updates off of subqueries in mysql.

Title: Table has pairs of matching records, need to select and update only one record

Body:
I have a table with pairs of matching records that I query like this:

select id,name,amount,type from accounting_entries
  where name like "%05" and amount != 0 order by name limit 10;

Results:

+------+----------------------+--------+-------+
| id   | name                 | amount | type  |
+------+----------------------+--------+-------+
|  786 | D-1194-838HELLUJP-05 |  -5800 | DEBIT |
|  785 | D-1194-838HELLUJP-05 |  -5800 | DEBIT |
| 5060 | D-1195-UOK4HS5POF-05 |  -5000 | DEBIT |
| 5059 | D-1195-UOK4HS5POF-05 |  -5000 | DEBIT |
|  246 | D-1196-0FUCJI66BX-05 |  -7000 | DEBIT |
|  245 | D-1196-0FUCJI66BX-05 |  -7000 | DEBIT |
| 9720 | D-1197-W2J0EC1BOB-05 |  -6500 | DEBIT |
| 9719 | D-1197-W2J0EC1BOB-05 |  -6500 | DEBIT |
| 2694 | D-1198-MFKIKHGW0S-05 |  -5500 | DEBIT |
| 2693 | D-1198-MFKIKHGW0S-05 |  -5500 | DEBIT |
+------+----------------------+--------+-------+
10 rows in set (0.01 sec)

I need to perform an update so that the resulting data will look like this:

+------+----------------------+--------+--------+
| id   | name                 | amount | type   |
+------+----------------------+--------+--------+
|  786 | D-1194-838HELLUJP-05 |  -5800 | DEBIT  |
|  785 | C-1194-838HELLUJP-05 |   5800 | CREDIT |
| 5060 | D-1195-UOK4HS5POF-05 |  -5000 | DEBIT  |
| 5059 | C-1195-UOK4HS5POF-05 |   5000 | CREDIT |
|  246 | D-1196-0FUCJI66BX-05 |  -7000 | DEBIT  |
|  245 | C-1196-0FUCJI66BX-05 |   7000 | CREDIT |
| 9720 | D-1197-W2J0EC1BOB-05 |  -6500 | DEBIT  |
| 9719 | C-1197-W2J0EC1BOB-05 |   6500 | CREDIT |
| 2694 | D-1198-MFKIKHGW0S-05 |  -5500 | DEBIT  |
| 2693 | C-1198-MFKIKHGW0S-05 |   5500 | CREDIT |
+------+----------------------+--------+--------+
10 rows in set (0.01 sec)

One entry should negate the other entry. It doesn't matter if I update the first or second matching record, what matters is that one has a positive amount and the other has a negative amount. And the type and name need to be updated.

Any clues on how to do this? What would the update command look like? Maybe using a group by clause? I have some ideas on how to do it with a stored procedure, but can I do it with a simple update?

Body:
Try this:

UPDATE accounting_entries as ae
SET    name = 'C' + SubString(name, 1, Length(name) - 1))
       amount = amount * -1
       type = 'Credit'
WHERE  id =
         (SELECT MIN(id) FROM
            (SELECT * FROM accounting_entries) as temp
          GROUP BY name)

The key is the subquery in the WHERE section that limits the updates to the lowest ID of each name value. The assumption is that the lower ID is the one that you will always want to update. If this is not correct, then update the subquery based on whatever rule you would use.

Edit: Update to subquery based on technique found here, due to limitation on mysql defined here.

This query gives a method for updating all records at once (as it seemed like this is what the OP was looking for. However, the most efficient way to do this would be to enumerate through all records in code (php, asp.net, etc), and through code-based methods update the rows that needed to change. This would eliminate the performance issues inherent with running updates off of subqueries in mysql.


问:
How to update the model from the ajax by rest framework(csrf problem??)
I want to update the table row by from ajax

From auto generated form (by rest framweorks) posting and updating works correctly.

However from ajax it shows

"POST /api/issues/372/ HTTP/1.1" 403 58 error

I googled around and found that this is related with csrt.

However How can I send correct json???

```<code>var json = {
         "id": 37;
         "name": "This is my new name",
         "color": "#dddddd"
};

$.ajax({
        type:"POST",
        url: "{% url 'issues-detail' 372 %}",
        data:JSON.stringify(json),
        contentType: 'application/JSON',
        dataType: "JSON",
        success: function(response) {
            console.log(response);
        },
        error: function(response) {
            console.log(response);
        },
        complete: function() {
            console.log("complete");
        }
});
</code>```

答:
you can add this code to your js file in document.ready function

```<code>$(document).ready(function() {
  $.ajaxSetup({

    beforeSend: function(xhr, settings) {
      if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url)))
      {
        // Only send the token to relative URLs i.e. locally.
        xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
      }
    }
  });
});
</code>```

For sending POST request we need to set csrf-token.

Body:
I want to update the table row by from ajax

From auto generated form (by rest framweorks) posting and updating works correctly.

However from ajax it shows

"POST /api/issues/372/ HTTP/1.1" 403 58 error

I googled around and found that this is related with csrt.

However How can I send correct json???

var json = {
         "id": 37;
         "name": "This is my new name",
         "color": "#dddddd"
};

$.ajax({
        type:"POST",
        url: "{% url 'issues-detail' 372 %}",
        data:JSON.stringify(json),
        contentType: 'application/JSON',
        dataType: "JSON",
        success: function(response) {
            console.log(response);
        },
        error: function(response) {
            console.log(response);
        },
        complete: function() {
            console.log("complete");
        }
});

Body:
you can add this code to your js file in document.ready function

$(document).ready(function() {
  $.ajaxSetup({

    beforeSend: function(xhr, settings) {
      if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url)))
      {
        // Only send the token to relative URLs i.e. locally.
        xhr.setRequestHeader("X-CSRFToken", getCookie("csrftoken"));
      }
    }
  });
});

For sending POST request we need to set csrf-token.


问:
ContentLoadingProgressBar is not displaying for a minimum amount of time before hiding
I'm trying to use ContentLoadingProgressBar to display 1 second before hiding itself. However I can't seem to find any examples of how to use it correctly with a recyclerview.

So I've tried using just testing it, but I can't get it to display for a minimum amount of time. How would I do so?

```<code><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.core.widget.ContentLoadingProgressBar
        android:id="@+id/main_progressbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        style="?android:attr/progressBarStyleLarge"
        android:visibility="visible"/>

</RelativeLayout>
</code>```

I've simply just tried doing it like this:

```<code>mProgressBar.show();
mProgressBar.hide();
</code>```

However it's not displaying for 1 second before hiding. It just hides automatically.

答:
ContentLoadinProgressBar is built to prevent flickering of UI during frequent show hide calls of progressBar. So if you quickly call hide();  after calling show(); then it'll ignore the show();. which is normal. to prevent flickering.

Have a look at Charuක's Answer

Body:
I'm trying to use ContentLoadingProgressBar to display 1 second before hiding itself. However I can't seem to find any examples of how to use it correctly with a recyclerview.

So I've tried using just testing it, but I can't get it to display for a minimum amount of time. How would I do so?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <androidx.core.widget.ContentLoadingProgressBar
        android:id="@+id/main_progressbar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        style="?android:attr/progressBarStyleLarge"
        android:visibility="visible"/>

</RelativeLayout>

I've simply just tried doing it like this:

mProgressBar.show();
mProgressBar.hide();

However it's not displaying for 1 second before hiding. It just hides automatically.


问:
ORA-28040: No matching authentication protocol : Oracle 12c Upgrade
We have migrated our Oracle database to 12c from 11g.
We have a legacy application running in Java 1.5 and using ojdbc14.jar.

Our application is not able to create connection to database error saying :

```<code>java.sql.SQLException: ORA-28040: No matching authentication protocol
</code>```

I reffered to answer ORA-28040: No matching authentication protocol exception, and tried to upgrade my ojdbc14.jar to ojdbc6.jar.

I now have a different error message saying :

```<code>  error: OracleCallableStatement is not public in oracle.jdbc.driver; cannot be accessed from outside package
import oracle.jdbc.driver.OracleCallableStatement;
                          ^
error: OracleTypes is not public in oracle.jdbc.driver; cannot be accessed from outside package
            cstmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
                                           ^
</code>```

Ant build file :

```<code><javac srcdir="${src}" destdir="${classes}" source="1.5" target="1.5">
            <classpath refid="cpath" />
</javac>
</code>```

Not sure what exactly we should do to get the application working.

答:
We had this error when we moved from 11g to 12c, I am able to get correct response through tnsping "servername" (this is the first step that we need to check through cmd).
After this we realize that database server is enable to handle only 64bit request (In my case I was using WinSQL and it always check for 32bit).
So to correct this, ask your admin to eanble server for 32 bit request as well or you can move to SQL developer which work for me.</p>

Body:
We have migrated our Oracle database to 12c from 11g.
We have a legacy application running in Java 1.5 and using ojdbc14.jar.

Our application is not able to create connection to database error saying :

java.sql.SQLException: ORA-28040: No matching authentication protocol

I reffered to answer ORA-28040: No matching authentication protocol exception, and tried to upgrade my ojdbc14.jar to ojdbc6.jar.

I now have a different error message saying :

  error: OracleCallableStatement is not public in oracle.jdbc.driver; cannot be accessed from outside package
import oracle.jdbc.driver.OracleCallableStatement;
                          ^
error: OracleTypes is not public in oracle.jdbc.driver; cannot be accessed from outside package
            cstmt.registerOutParameter(3,oracle.jdbc.driver.OracleTypes.CURSOR);
                                           ^

Ant build file :

<javac srcdir="${src}" destdir="${classes}" source="1.5" target="1.5">
            <classpath refid="cpath" />
</javac>

Not sure what exactly we should do to get the application working.


问:
How to read specific column one by one till the defined column number?
I have existing codes that work to get a particular cell from an excel sheet.

I have input data in excel sheet from cell C2 till cell T2.

Current codes allowed me to read cell C2 once.

I wanted to make it automatically read C2, D2, E2, ..... till T2

Codes:

public String ReadCellData(int vRow, int vColumn)
 {
  String value=null;          //variable for storing the cell value
  Workbook wb=null;           //initialize Workbook null
  try
  {
   //reading data from a file in the form of bytes
      FileInputStream fis=new FileInputStream(RunConfiguration.getProjectDir() + "/Data Files/testmatrix.xlsx");
   //constructs an XSSFWorkbook object, by buffering the whole stream into the memory
   wb=new XSSFWorkbook(fis);
  }
  catch(FileNotFoundException e)
  {
   e.printStackTrace();
  }
  catch(IOException e1)
  {
   e1.printStackTrace();
  }
  Sheet sheet=wb.getSheetAt(0);   //getting the XSSFSheet object at given index
  Row row=sheet.getRow(vRow); //returns the logical row
  Cell cell=row.getCell(vColumn); //getting the cell representing the given column
  //value=cell.getStringCellValue();    //getting cell value
  //return value;               //returns the cell value
 }
}```
</div>
</div>
</p>

<p><strong>codes to get and print data</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>//read excel cell C2, ignore first row column A1. (int vRow, int vColumn)
def exceldata = CustomKeywords.'test.readexcel.ReadCellData'(2, 2)

String jsondata = JsonOutput.prettyPrint(exceldata.toString())

println(jsondata)

WebUI.delay(1)

//call the object and post the above data as API HTTP request body
def post = ((findTestObject('Object Repository/Web Service Request/test-service/Post')) as RequestObject)

post.setBodyContent(new HttpTextBodyContent(jsondata))

WebUI.delay(2)

//POST and verification
def response = WS.sendRequestAndVerify(post)

println(response.statusCode)

assert response.getStatusCode() == 201</code>```

答:
Use the For loop and iterate the loop and get the value

Example

```<code>def exceldata="";
for(int row =1;row<=2;row++)
{
for(int col=1;col<=5;col++)
{
exceldata = CustomKeywords.'test.readexcel.ReadCellData'(row,col)
}
}
</code>```

Body:
I have existing codes that work to get a particular cell from an excel sheet.

I have input data in excel sheet from cell C2 till cell T2.

Current codes allowed me to read cell C2 once.

I wanted to make it automatically read C2, D2, E2, ..... till T2

Codes:

public String ReadCellData(int vRow, int vColumn)
 {
  String value=null;          //variable for storing the cell value
  Workbook wb=null;           //initialize Workbook null
  try
  {
   //reading data from a file in the form of bytes
      FileInputStream fis=new FileInputStream(RunConfiguration.getProjectDir() + "/Data Files/testmatrix.xlsx");
   //constructs an XSSFWorkbook object, by buffering the whole stream into the memory
   wb=new XSSFWorkbook(fis);
  }
  catch(FileNotFoundException e)
  {
   e.printStackTrace();
  }
  catch(IOException e1)
  {
   e1.printStackTrace();
  }
  Sheet sheet=wb.getSheetAt(0);   //getting the XSSFSheet object at given index
  Row row=sheet.getRow(vRow); //returns the logical row
  Cell cell=row.getCell(vColumn); //getting the cell representing the given column
  //value=cell.getStringCellValue();    //getting cell value
  //return value;               //returns the cell value
 }
}

codes to get and print data

//read excel cell C2, ignore first row column A1. (int vRow, int vColumn)
def exceldata = CustomKeywords.'test.readexcel.ReadCellData'(2, 2)

String jsondata = JsonOutput.prettyPrint(exceldata.toString())

println(jsondata)

WebUI.delay(1)

//call the object and post the above data as API HTTP request body
def post = ((findTestObject('Object Repository/Web Service Request/test-service/Post')) as RequestObject)

post.setBodyContent(new HttpTextBodyContent(jsondata))

WebUI.delay(2)

//POST and verification
def response = WS.sendRequestAndVerify(post)

println(response.statusCode)

assert response.getStatusCode() == 201

Body:
Use the For loop and iterate the loop and get the value

Example

def exceldata="";
for(int row =1;row<=2;row++)
{
for(int col=1;col<=5;col++)
{
exceldata = CustomKeywords.'test.readexcel.ReadCellData'(row,col)
}
}