Some Trials & a lot of Errors

I tried a bunch of framework and other language and I usually feel overwhelm when its time to do something real with what I've learned. So that why I created this site, to write my progress and help some noob like me that stumble into the sames problems.

Browse: Page 2

JENKINS: How to fix a java.net.NoRouteToHostException.

By Chris on October 5, 2014

Our build server (jenkins) had that error

 

BUILD FAILED

com.jcraft.jsch.JSchException: java.net.NoRouteToHostException: No route to host

Full stack trace below if you really need it. I assume there was a problem with where Jenkins was deploying the apps or at a issue trying to run integration test on the remote server. After talking to IT it seem I was right. the server were Jenkins deploys the app was down (physically down). We had to restart it and then it worked fine.

Full stack :

BUILD FAILED

com.jcraft.jsch.JSchException: java.net.NoRouteToHostException: No route to host

at com.jcraft.jsch.Util.createSocket(Util.java:341)

at com.jcraft.jsch.Session.connect(Session.java:186)

at com.jcraft.jsch.Session.connect(Session.java:154)

at org.apache.tools.ant.taskdefs.optional.ssh.SSHBase.openSession(SSHBase.java:212)

at org.apache.tools.ant.taskdefs.optional.ssh.SSHExec.execute(SSHExec.java:158)

at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)

at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

at org.apache.tools.ant.Task.perform(Task.java:348)

at org.apache.tools.ant.Target.execute(Target.java:357)

at org.apache.tools.ant.Target.performTasks(Target.java:385)

at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)

at org.apache.tools.ant.Project.executeTarget(Project.java:1306)

at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)

at org.apache.tools.ant.Project.executeTargets(Project.java:1189)

at org.apache.tools.ant.Main.runBuild(Main.java:758)

at org.apache.tools.ant.Main.startAnt(Main.java:217)

at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)

at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Caused by: java.net.NoRouteToHostException: No route to host

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

at java.net.Socket.connect(Socket.java:529)

at java.net.Socket.connect(Socket.java:478)

at java.net.Socket.<init>(Socket.java:375)

at java.net.Socket.<init>(Socket.java:189)

at com.jcraft.jsch.Util.createSocket(Util.java:335)

… 20 more

 

Posted in prog | Tagged build server, java, jenkins | Leave a response

Why is String not sorting with the Local ?

By Chris on September 28, 2014

Comparing and sorting Strings might not work out like you expected specially when your dealing with a language other than English.

Normally comparing strings in done with simple Unicode ordering. If you want to have localized ordering (the kind expected by an end user) you need to use a Collator.

Commonly used String methods such as:

  • String.equalsIgnoreCase(String)
  • String.compareTo(String)

can have unexpected result depending on the context you’re using them. The reason is that programmers tend to apply them to tasks they really aren’t meant for, simply out of habit.

The fundamental difference is that localized comparison depends on Locale, while String is largely ignorant of Locale.

The only robust way of doing localized comparison or sorting of Strings, in the manner expected by an end user, is to use a Collator, not the methods of the String class.

For more info check out the code example at http://www.javapractices.com or at http://www.guru99.com/java-strings.html

Posted in java, prog | Tagged collator, java, sorting, String | Leave a response

Oracle doesn’t support limit

By Chris on September 20, 2014

My god sometime I bang my head on the wall to do something simple on oracle. So oracle don’t support limit so to do something simple has :

SELECT f_name, l_name, age from
employee_data ORDER BY age DESC
LIMIT 20

become :

SELECT f_name, l_name, age
FROM
( SELECT f_name, l_name, age, ROWNUM r
FROM
( SELECT f_name, l_name, age FROM employee_data 
      ORDER BY age DESC
)
WHERE ROWNUM <= 40
)
WHERE r >= 21;

 

Posted in db, prog | Tagged limit, oracle, sql | Leave a response

Update table using Inner Join return ORA-00933

By Chris on September 13, 2014

I was trying to update a table that using sql join but I kept getting ORA-00933  

I tried the following:

Using A SQL JOIN In A SQL UPDATE Statement Using A SQL JOIN In A SQL UPDATE Statement (www.bennadel.com)

update table using inner join (venushuynh.wordpress.com)

but I kept getting the ORA-00933

then tried this Oracle Update with Join (geekswithblogs.net) but still didn’t work.

After some deep search I’ve found my error in a oracle forum: SQL Error: ORA-01779: cannot modify a column which maps to a non key-preser

Even though it’s not the same ORA error it fixed the problem nonetheless

Here my sql statement that worked for me:

UPDATE mytable m

set m.status=7

where m.id in (select mytable.id from mytable inner join otherTable on mytable.matchid=othertable.matchid where othertable.userid=1234)

Posted in db | Tagged db, error, oracle | Leave a response

Hibernate Session saveOrUpdate does not update

By Chris on September 7, 2014

Another problem I’ve it recently with saveOrUpdate that can be fix by using the same saveOrUpdate but give the class name.

Using the session.saveOrUpdate(myObject) might give you a unknown entity while using the same method with the class name in parameter won’t.

session.saveOrUpdate(myObject); //give a unknown entity
session.saveOrUpdate("MyObjectClassName", MyObject); //Work

The important difference between the org.hibernate.Session class methods, save & saveOrUpdate is, save generates a new identifier and results in an INSERT query, whereas saveOrUpdate does an INSERT or an UPDATE.

For a more complete summary of what each of these method do check the hibernate site or this stackoverflow question/answer

Posted in db, prog | Tagged db, hibernate | Leave a response

Lessons learned: Why struts not working ?

By Chris on September 2, 2014

If you happen to rename your folder that contain your jsp and js, don’t forget to update the struts config (and the tiles). This will save your precious time even hours …

Posted in java | Tagged java, javascript, js, jsp, struts | Leave a response

Oracle have no Boolean, how to fix this

By Chris on August 30, 2014

For some reason Oracle have no Boolean

Since there is no BOOLEAN datatype in Oracle, as far as tables are concerned.

CREATE TABLE BooleanTable (MyBool BOOLEAN);

return :

ORA-00902: invalid datatype

But there is a BOOLEAN datatype in PL/SQL.

What should we do instead?

According to Tom at ThinkOracle you could create the table using char like this :

CREATE TABLE BoolTable (MyBool CHAR(1) CHECK (MyBool IN ( 'Y', 'N' )));

In our case (where I used to worked) we used Number instead. Same thing we did with the char but instead of “y/n” we use ‘0’ or ‘1’ where ‘0’ = false and ‘1’ = true

Related:

http://thinkoracle.blogspot.ca/2005/07/oracle-boolean.html

Posted in db | Tagged boolean, oracle, pl/sql, sql | 1 Response

Jmeter: ERROR – jmeter.save.SaveService: Conversion error

By Chris on August 23, 2014


One of our engineer made some change to the Jmeter script and I couldn’t find what was the error. The test was giving me “Error in TestPlan – see log file”

After some digging I found out there was an ext lib missing.

ERROR - jmeter.save.SaveService: Conversion error com.thoughtworks.xstream.converters.ConversionException: kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

—- Debugging information —-

message : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

cause-exception    : com.thoughtworks.xstream.mapper.CannotResolveClassException

cause-message : kg.apc.jmeter.threads.SteppingThreadGroup : kg.apc.jmeter.threads.SteppingThreadGroup

class   : org.apache.jorphan.collections.ListedHashTree

required-type : org.apache.jorphan.collections.ListedHashTree

path: /jmeterTestPlan/hashTree/hashTree/kg.apc.jmeter.threads.SteppingThreadGroup

 

Finally this error was due to 2 things

1- We needed to have the same version of jmeter than the other programmer was using (2.5.1 + at the time)

2- We needed a library that I didn’t know about http://jmeter-plugins.googlecode.com/files/JMeterPlugins-0.5.1.zip

Posted in jmeter | Tagged jmeter, load testing | Leave a response

How to handle a single quote in Oracle SQL

By Chris on August 9, 2014

When you are handling string you sometime have single quote in your string. I was looking on how to handle that in Oracle and it’s not pretty but you can cover that case with the chr(39) function, 39 being the code for the single quote.

So it you are looking the “it’s” you have to look for “it‘||CHR(39)||’s”

I’ve read I’ve could have use 2 quote or the $ in latter version. In that case:

 

SELECT 'it''s' name FROM DUAL;

Or use the new (10g+) quoting method

SELECT q'$it's$' NAME FROM DUAL;

Note I’ve used the chr(39) and worked fine for me I didn’t try the other one, so good luck with that.

Posted in db, prog | Tagged oracle, quote, single quote, sql | Leave a response

[Oracle Fun] Converting ORACLE to mySQL datatype

By Chris on August 2, 2014

 

I had in the past had to work with oracle and had to convert it to mysql. Unfortunately (or fortunately) that project was cancel but here are the bit of information I’ve found that I didn’t know about and made me lost a lot of time.

 

Oracle vs mySQL datatype edition

From mySQL Forum:

NUMBER Any NUMERIC
DEC Any NUMERIC
DECIMAL Any NUMERIC
NUMERIC Any NUMERIC
DOUBLE PRECISION Any NUMERIC
FLOAT Any NUMERIC
REAL Any NUMERIC
SMALLINT Any SMALLINT
VARCHAR <256 VARCHAR
VARCHAR2 <256 VARCHAR
CHAR <256 CHAR
VARCHAR2 >255 TEXT
VARCHAR >255 TEXT
CHAR >255 TEXT
LONG <256 VARCHAR
LONGRAW <256 VARCHAR
RAW <256 VARCHAR
LONG >255 TEXT
LONGRAW >255 TEXT
RAW >255 TEXT
DATE – DATETIME (Since DATE in oracle can include time information!)

From what we needed we had to

decimal(50,0) = NUMBER

decimal(22,0) = INTEGER

DATE = datetime

Now that I look at it I think It would have been better to turn them both to number.

The best course of action is to find a DBA and use tool for the job like omega sync like it’s recommended in the following stackoverflow thread.

Posted in db, prog | Tagged db, migration, mysql, oracle | Leave a response

« PreviousNext »

Tags

4hww 2018 about addiction arraylist book ClassLoaders date dating db deployment DeploymentException errors hibernate icon ideas j2ee java java.util.List jboss linux List memory motivation mysql netstat oracle port programing quora rest reviews self help soap sql star startup String struts struts tag styleClass tags to_date welcome windows

Recent Comments

  • kevin on Oracle have no Boolean, how to fix this

Calendar

January 2021
MonTueWedThuFriSatSun
« May  
 123
45678910
11121314151617
18192021222324
25262728293031

Archives

  • May 2020
  • January 2019
  • December 2018
  • July 2018
  • April 2018
  • January 2018
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013

Copyright © 2021 Some Trials & a lot of Errors.

Powered by WordPress and Hybrid.