Tuesday, December 26, 2017

Find the used ports in machine

We need to find the all the used ports in a machine. We can get to know easily with the command

netstat -ano

this will give the output as

Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:85             0.0.0.0:0              LISTENING       5180
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       892


IF you need to verify the PID with the processes, open Task Manager. This will show 'PID'

netstat -ano > log.txt

Tuesday, October 3, 2017

Cannot insert explicit value for identity column in table 'TableName' when IDENTITY_INSERT is set to OFF

You must have experience above error

Cannot insert explicit value for identity column in table 'TableName' when IDENTITY_INSERT is set to OFF

Reason: I have used annotation for hibernate. In my class i have not specified the "GenerationType" for the


@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "ID", unique = true, nullable = false)
public int getId() {
return id;
}



-----------------error-----------



SEVERE: Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not insert: [com.sqlserver.test.RestoreUSFinanceCube]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.sqlserver.test.main.AppUSCube.saveEntry(AppUSCube.java:37)
at com.sqlserver.test.main.AppUSCube.main(AppUSCube.java:18)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'RESTORE_US_FINANCE_CUBE' when IDENTITY_INSERT is set to OFF.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:232)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1672)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:460)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:405)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7535)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2438)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:208)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:183)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:348)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
... 12 more

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.sqlserver.test.RestoreUSFinanceCube]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.sqlserver.test.main.AppUSCube.saveEntry(AppUSCube.java:37)
at com.sqlserver.test.main.AppUSCube.main(AppUSCube.java:18)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot insert explicit value for identity column in table 'RESTORE_US_FINANCE_CUBE' when IDENTITY_INSERT is set to OFF.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:232)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1672)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:460)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:405)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7535)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2438)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:208)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:183)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:348)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
... 12 more



Sunday, August 6, 2017

Spring Boot - Article 1

So what is Spring Boot ?

You must have heard the word "Spring". It is well known framework for Java developers. In simple, Spring is basically an Application Framework (which includes so many concepts like inversion of container...etc) for Java developers which helps to build applications using Spring's core features and more powerful features with build in and plugin extensions.

So what is Spring Boot then ?
Here are few explanation i came a cross in internet.

Spring Boot is a brand new framework from the team at Pivotal, designed to simplify the bootstrapping and development of a new Spring application. The framework takes an opinionated approach to configuration, freeing developers from the need to define boilerplate configuration.

Well looks to be lots of jargon of words :)

So what is it ?

Spring Boot makes it easy to create stand-alone, production-grade, Spring based applications that you can just run.

Here are some of the words/jargon which comes with the Spring Boot


  • Opinionated
  • Convention over Configuration
  • Stands alone
  • Production ready






Tuesday, February 21, 2017

Generate machine key - Windows

You may need to generate machine in configuring servers in various deployment / server configurations in windows based systems. Here I explain how to generate machine keys (validation key , decryption key ) using IIS.
If IIS does not have "machine key" , then install "ASP.NET" under "Server Roles --> Web Server IIS --> Application development" in install features.




1. select "machine key " from IIS Home . Right Click "machine key" and select "Open feature"



2. In machine key generate window, slect the validation metho and Encryption method as per requirement and click "generate Keys"





You will get the keys, as shown above.