Copy new/updated files from source folder on D to destination folder on K
xcopy D:\Documents\Pictures K:\Documents\Pictures /s /d
Sunday, December 4, 2016
Thursday, December 1, 2016
Linux Notes
uname -r: shows kernel version
lsb_release -a: shows operating system/distribution
free -m: shows memory
Ubuntu/Lubuntu/Centos/Raspberry Pi (Raspbian, Debian based distribution)
lsb_release -a: shows operating system/distribution
free -m: shows memory
Ubuntu/Lubuntu/Centos/Raspberry Pi (Raspbian, Debian based distribution)
Thursday, November 17, 2016
Joda-Time DateTimeFormat
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
DateTime showDate = formatter.parseDateTime("02/02/2016 08:02:00");
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
DateTimeFormatter formatter = DateTimeFormat.forPattern("dd/MM/yyyy HH:mm:ss");
DateTime showDate = formatter.parseDateTime("02/02/2016 08:02:00");
facebook4j Events
import facebook4j.Event;
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;
Facebook facebook = new FacebookFactory().getInstance();
facebook.setOAuthAppId(appId, appSecret);
facebook.setOAuthPermissions(commaSeparetedPermissions);
facebook.setOAuthAccessToken(new AccessToken(accessToken, null));
ResponseList<Event> events;
int count;
try {
events = facebook.getEvents();
count = events.size();
} catch (FacebookException e) {
e.printStackTrace();
}
import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;
Facebook facebook = new FacebookFactory().getInstance();
facebook.setOAuthAppId(appId, appSecret);
facebook.setOAuthPermissions(commaSeparetedPermissions);
facebook.setOAuthAccessToken(new AccessToken(accessToken, null));
ResponseList<Event> events;
int count;
try {
events = facebook.getEvents();
count = events.size();
} catch (FacebookException e) {
e.printStackTrace();
}
Saturday, October 29, 2016
Thursday, September 22, 2016
Wednesday, September 14, 2016
Sunday, August 28, 2016
Monday, August 8, 2016
Today I Read: How to use Servlets and Ajax
How to use Servlets and Ajax
http://stackoverflow.com/questions/4112686/how-to-use-servlets-and-ajax/
http://stackoverflow.com/questions/4112686/how-to-use-servlets-and-ajax/
Friday, August 5, 2016
MemcacheService, BigInteger, and Byte Array
MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
IdentifiableValue oldValue = syncCache.getIdentifiable(key);
BigInteger.valueOf(0).toByteArray()
byte[] newValue = increment((byte[]) oldValue.getValue());
new BigInteger(newValue).intValue()
syncCache.putIfUntouched(key, oldValue, newValue)
break;
Thread.sleep(delayMs);
private byte[] increment(byte[] oldValue) {
long val = new BigInteger(oldValue).intValue();
val++;
return BigInteger.valueOf(val).toByteArray();
}
IdentifiableValue oldValue = syncCache.getIdentifiable(key);
BigInteger.valueOf(0).toByteArray()
byte[] newValue = increment((byte[]) oldValue.getValue());
new BigInteger(newValue).intValue()
syncCache.putIfUntouched(key, oldValue, newValue)
break;
Thread.sleep(delayMs);
private byte[] increment(byte[] oldValue) {
long val = new BigInteger(oldValue).intValue();
val++;
return BigInteger.valueOf(val).toByteArray();
}
Thursday, August 4, 2016
Oracle decode() and sign() functions and count(*) - count(COLUMN_NAME)
decode(sign(count(*) - count(COLUMN_NAME)), 1, 'Y', 'N')
1) count(*) - count(COLUMN_NAME): returns a count of non-null records, used with group by
2) sign(NUMBER): returns sign of NUMBER
If NUMBER < 0, then sign returns -1
If NUMBER = 0, then sign returns 0
If NUMBER > 0, then sign returns 1
3) decode(sign(NUMBER), 1, 'Y', 'N'): if NUMBER is greater than 0, then returns 'Y', otherwise returns 'N'
1) count(*) - count(COLUMN_NAME): returns a count of non-null records, used with group by
2) sign(NUMBER): returns sign of NUMBER
If NUMBER < 0, then sign returns -1
If NUMBER = 0, then sign returns 0
If NUMBER > 0, then sign returns 1
3) decode(sign(NUMBER), 1, 'Y', 'N'): if NUMBER is greater than 0, then returns 'Y', otherwise returns 'N'
Tuesday, July 26, 2016
.NET Oracle Client
Method 1: Web.config
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</configSections>
<dataConfiguration defaultDatabase="DefaultDatabase">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.DDTekOracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="DDTek.Oracle"/>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Oracle.DataAccess.Client" />
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="ConnectionString1" providerName="Oracle.DataAccess.Client" connectionString="User Id=;Password=;Data Source=; Pooling=true; Min Pool Size=1; Max Pool Size=50; Incr Pool Size=10; Decr Pool Size=10; Connection Timeout=50; Validate Connection=true;"/>
</connectionStrings>
</configuration>
Method 2: Web.config
<connectionStrings>
<add name="ConnectionString1" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=;Password=;Data Source=; Pooling=true; Min Pool Size=1; Max Pool Size=50; Incr Pool Size=10; Decr Pool Size=10; Connection Timeout=50; Validate Connection=true;"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<remove invariant="Oracle.DataAccess.Client" />
<add name="Oracle Data Provider for .NET"
invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="ODP.NET, Managed Driver"
invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
Method 3: Machine.config
<system.data>
<DbProviderFactories>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
<section name="oracle.dataaccess.client" type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
</configSections>
<dataConfiguration defaultDatabase="DefaultDatabase">
<providerMappings>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.DDTekOracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="DDTek.Oracle"/>
<add databaseType="Microsoft.Practices.EnterpriseLibrary.Data.Oracle.OracleDatabase, Microsoft.Practices.EnterpriseLibrary.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="Oracle.DataAccess.Client" />
</providerMappings>
</dataConfiguration>
<connectionStrings>
<add name="ConnectionString1" providerName="Oracle.DataAccess.Client" connectionString="User Id=;Password=;Data Source=; Pooling=true; Min Pool Size=1; Max Pool Size=50; Incr Pool Size=10; Decr Pool Size=10; Connection Timeout=50; Validate Connection=true;"/>
</connectionStrings>
</configuration>
Method 2: Web.config
<connectionStrings>
<add name="ConnectionString1" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=;Password=;Data Source=; Pooling=true; Min Pool Size=1; Max Pool Size=50; Incr Pool Size=10; Decr Pool Size=10; Connection Timeout=50; Validate Connection=true;"/>
</connectionStrings>
<system.data>
<DbProviderFactories>
<remove invariant="Oracle.ManagedDataAccess.Client" />
<remove invariant="Oracle.DataAccess.Client" />
<add name="Oracle Data Provider for .NET"
invariant="Oracle.DataAccess.Client"
description="Oracle Data Provider for .NET"
type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
<add name="ODP.NET, Managed Driver"
invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
Method 3: Machine.config
<system.data>
<DbProviderFactories>
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
Sunday, July 24, 2016
Issue: Unable to fetch transient dependency com.google.http-client:google-http-client:[1.19.0,2.0)
Issue:
Unable to fetch transient dependency com.google.http-client:google-http-client:[1.19.0,2.0)
Solution
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.6</version>
<exclusions>
<exclusion>
<!-- TODO remove me after the issue is fixed https://github.com/google/google-http-java-client/issues/330 -->
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add the transitive dependency explicity -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.22.0</version>
</dependency>
Unable to fetch transient dependency com.google.http-client:google-http-client:[1.19.0,2.0)
Solution
<dependency>
<groupId>com.google.appengine.tools</groupId>
<artifactId>appengine-gcs-client</artifactId>
<version>0.6</version>
<exclusions>
<exclusion>
<!-- TODO remove me after the issue is fixed https://github.com/google/google-http-java-client/issues/330 -->
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add the transitive dependency explicity -->
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.22.0</version>
</dependency>
Wednesday, July 6, 2016
Bootstrap Carousel
http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=carousel
https://bootstrapbay.com/blog/bootstrap-3-carousel-tutorial/
https://bootstrapbay.com/blog/bootstrap-3-carousel-tutorial/
GAE URLFetchService, JDOM2, Amazon ItemSearch, Bytes Array to String
https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/appengine/urlfetch
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html
http://stackoverflow.com/questions/4661680/how-to-read-fetch-the-xml-file-from-an-url-using-java
http://stackoverflow.com/posts/4661726/revisions
http://www.tutorialspoint.com/java_xml/java_jdom_query_document.htm
http://www.studytrails.com/java/xml/jdom2/java-xml-jdom2-xpath.jsp
http://www.tutorialspoint.com/java_xml/java_jdom_parse_document.htm
https://ikaisays.com/2010/06/29/using-asynchronous-urlfetch-on-java-app-engine/
byte[] bytes = example.getBytes();
String decoded = new String(bytes, "UTF-8");
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html
http://stackoverflow.com/questions/4661680/how-to-read-fetch-the-xml-file-from-an-url-using-java
http://stackoverflow.com/posts/4661726/revisions
http://www.tutorialspoint.com/java_xml/java_jdom_query_document.htm
http://www.studytrails.com/java/xml/jdom2/java-xml-jdom2-xpath.jsp
http://www.tutorialspoint.com/java_xml/java_jdom_parse_document.htm
https://ikaisays.com/2010/06/29/using-asynchronous-urlfetch-on-java-app-engine/
byte[] bytes = example.getBytes();
String decoded = new String(bytes, "UTF-8");
Thursday, June 30, 2016
.NET 4.5.2 TLS1.2
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
"SchUseStrongCrypto"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319]
"SchUseStrongCrypto"=dword:00000001
Tuesday, June 21, 2016
GAE Modules/Services
http://stackoverflow.com/questions/23055616/appengine-modules-dispatch-xml-routing-with-custom-domain
https://cloud.google.com/appengine/docs/java/config/dispatchref
https://github.com/GoogleCloudPlatform/appengine-modules-sample-java
https://cloud.google.com/appengine/docs/java/microservices-on-app-engine
https://cloud.google.com/appengine/docs/java/modules/converting
https://cloud.google.com/appengine/docs/java/config/dispatchref
https://github.com/GoogleCloudPlatform/appengine-modules-sample-java
https://cloud.google.com/appengine/docs/java/microservices-on-app-engine
https://cloud.google.com/appengine/docs/java/modules/converting
Thursday, June 16, 2016
Java HashMap
Map<Integer,String> uniqueMap =
new
HashMap<Integer,String>();
List<Value> list = new ArrayList<Value>(map.values());
map.size()
Thursday, May 19, 2016
Thursday, May 12, 2016
Thursday, April 21, 2016
Tell Git to Ignore File Changes
git update-index --assume-unchanged doc.asciidoc
git ls-files -v | grep '^[hsmrck?]' | cut -c 3-
git update-index --no-assume-unchanged doc.asciidoc
git ls-files -v | grep '^[hsmrck?]' | cut -c 3-
git update-index --no-assume-unchanged doc.asciidoc
Clean Working Directory with Git
git reset --hard
git clean -xdf
Note: reset all files to their last-committed state and remove all uncommitted files
git clean -xdf
Note: reset all files to their last-committed state and remove all uncommitted files
Tuesday, April 12, 2016
Monday, April 11, 2016
TIL: Oracle BPEL Process Manager
BPEL is the standard for assembling a set of discrete services into an
end-to-end process flow, radically reducing the cost and complexity of
process integration initiatives. Oracle BPEL Process Manager offers a
comprehensive and easy-to-use infrastructure for creating, deploying and
managing BPEL business processes.
http://www.oracle.com/technetwork/middleware/bpel/overview/index.html
http://www.oracle.com/technetwork/middleware/bpel/overview/index.html
Sunday, April 10, 2016
Thursday, March 31, 2016
Monday, March 28, 2016
Windows wireless service is not running on this computer in Windows 10
Run the following commands in the command prompt as Administrator to fix the issue in Windows 10. A system restart will be required.
netsh winsock reset catalog
netsh int ip reset reset.log hit
netsh winsock reset catalog
netsh int ip reset reset.log hit
Sunday, March 27, 2016
BindingResult result follows validated object
BindingResult result has to follow the object show that it binds to properly validate the inputs. Otherwise, you'll get an exception similar to "field error in object on field rejected value codes".
@RequestMapping(value={"/addnewshow", "/editshow"}, method=RequestMethod.POST)
public String processShow(@Valid @ModelAttribute("show") Show show, BindingResult result,
@RequestParam(value="showid", required=false) Long showId)
{
if(result.hasErrors()){
return "myapp.editshow";
}
else{
show.setId(showId);
show = showService.save(show);
}
return "redirect:editshow.html?showid=" + show.getId();
}
@RequestMapping(value={"/addnewshow", "/editshow"}, method=RequestMethod.POST)
public String processShow(@Valid @ModelAttribute("show") Show show, BindingResult result,
@RequestParam(value="showid", required=false) Long showId)
{
if(result.hasErrors()){
return "myapp.editshow";
}
else{
show.setId(showId);
show = showService.save(show);
}
return "redirect:editshow.html?showid=" + show.getId();
}
Friday, March 25, 2016
Thursday, March 24, 2016
Wednesday, March 16, 2016
Querystring or Model values
<c:set var="showId" value="${param.showid}"/>
~
<c:set var="showId" value="${show.getId()}"/>
~
<c:set var="showId" value="${show.getId()}"/>
Monday, March 14, 2016
Java Config dataSourceInitializer
@Value("classpath:db/sql/insert-data.sql")
private org.springframework.core.io.Resource DATA_SCRIPT;
@Bean
public DataSourceInitializer dataSourceInitializer(final DataSource dataSource) {
final DataSourceInitializer initializer = new DataSourceInitializer();
initializer.setDataSource(dataSource);
initializer.setDatabasePopulator(databasePopulator());
return initializer;
}
private DatabasePopulator databasePopulator() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(DATA_SCRIPT);
return populator;
}
OR
populator.addScript(new ClassPathResource("db/sql/insert-data.sql"));
private org.springframework.core.io.Resource DATA_SCRIPT;
@Bean
public DataSourceInitializer dataSourceInitializer(final DataSource dataSource) {
final DataSourceInitializer initializer = new DataSourceInitializer();
initializer.setDataSource(dataSource);
initializer.setDatabasePopulator(databasePopulator());
return initializer;
}
private DatabasePopulator databasePopulator() {
final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(DATA_SCRIPT);
return populator;
}
OR
populator.addScript(new ClassPathResource("db/sql/insert-data.sql"));
Sunday, March 13, 2016
Saturday, February 27, 2016
JAVA JPA Goal Repository
JAVA JPA
//Repository
package com.thekhuc.repository;
import java.util.List;
import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;
public interface GoalRepository {
Goal save(Goal goal);
List<Goal> loadAll();
List<GoalReport> findAllGoalReports();
}
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.springframework.stereotype.Repository;
import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;
@Repository("goalRepository")
public class GoalRepositoryImpl implements GoalRepository {
@PersistenceContext
private EntityManager em;
@Override
public Goal save(Goal goal) {
if(goal.getId() == null){
em.persist(goal);
em.flush();
}
else{
goal = em.merge(goal);
}
return goal;
}
@Override
public List<Goal> loadAll() {
//Query query=em.createQuery("Select g from Goal g");
TypedQuery<Goal> query = em.createNamedQuery(Goal.FIND_ALL_GOALS, Goal.class);
return query.getResultList();
}
@Override
public List<GoalReport> findAllGoalReports() {
//Query query = em.createQuery("Select new com.thekhuc.model.GoalReport(g.minutes, e.minutes, e.activity) " +
// "from Goal g, Exercise e where g.id = e.goal.id");
TypedQuery<GoalReport> query = em.createNamedQuery(Goal.FIND_GOAL_REPORTS, GoalReport.class);
return query.getResultList();
}
}
//Repository
package com.thekhuc.repository;
import java.util.List;
import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;
public interface GoalRepository {
Goal save(Goal goal);
List<Goal> loadAll();
List<GoalReport> findAllGoalReports();
}
//Interface
package com.thekhuc.repository;import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.springframework.stereotype.Repository;
import com.thekhuc.model.Goal;
import com.thekhuc.model.GoalReport;
@Repository("goalRepository")
public class GoalRepositoryImpl implements GoalRepository {
@PersistenceContext
private EntityManager em;
@Override
public Goal save(Goal goal) {
if(goal.getId() == null){
em.persist(goal);
em.flush();
}
else{
goal = em.merge(goal);
}
return goal;
}
@Override
public List<Goal> loadAll() {
//Query query=em.createQuery("Select g from Goal g");
TypedQuery<Goal> query = em.createNamedQuery(Goal.FIND_ALL_GOALS, Goal.class);
return query.getResultList();
}
@Override
public List<GoalReport> findAllGoalReports() {
//Query query = em.createQuery("Select new com.thekhuc.model.GoalReport(g.minutes, e.minutes, e.activity) " +
// "from Goal g, Exercise e where g.id = e.goal.id");
TypedQuery<GoalReport> query = em.createNamedQuery(Goal.FIND_GOAL_REPORTS, GoalReport.class);
return query.getResultList();
}
}
Sunday, February 21, 2016
persistence.xml
/src/main/resources/META-INF/persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.or/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/XML/ns/persistence http://java.sun.com/xml/ns/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="punit"></persistence-unit>
</persistence>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.or/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/XML/ns/persistence http://java.sun.com/xml/ns/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="punit"></persistence-unit>
</persistence>
jpaContext.xml
/src/main/resources/jpaContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<context:annotation-config/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="punit"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<entry key="hibernate.hbm2ddl.auto" value="create"/>
<entry key="hibernate.format_sql" value="true"/>
</map>
</property>
</bean>
<bean id="transactionmanager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/fitnesstracker?autoReconnect=true"/>
<property name="username" value=""/>
<property name="password" value=""/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
<context:annotation-config/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="punit"/>
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true"/>
</bean>
</property>
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<entry key="hibernate.hbm2ddl.auto" value="create"/>
<entry key="hibernate.format_sql" value="true"/>
</map>
</property>
</bean>
<bean id="transactionmanager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/fitnesstracker?autoReconnect=true"/>
<property name="username" value=""/>
<property name="password" value=""/>
</bean>
</beans>
Friday, February 19, 2016
Monday, January 18, 2016
Subscribe to:
Posts (Atom)