Friday, March 22, 2019

XML Java Transformer outputs instead of <>

I share example how java Transformer outputs &lt; and &gt; instead of <> on XML.



import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;

import org.apache.commons.lang.StringEscapeUtils;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;

public class Test {

    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub

        String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
            "&lt;company&gt;" +
            "&lt;staff id=\"1001\"&gt;" +
            "&lt;firstname&gt;henry&lt;/firstname&gt;" +
            "&lt;/staff&gt;" +

        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(new InputSource(new StringReader(StringEscapeUtils.unescapeXml(xml.toString()))));

        System.out.println("final xml " + xmlTransformerInput(doc).toString());


    public static String xmlTransformerInput(Document fDoc) {

        try {

            DOMSource docSource = new DOMSource(fDoc);
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty(OutputKeys.METHOD, "xml");
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            StringWriter sw = new StringWriter();
            transformer.transform(docSource, new StreamResult(sw));

            return sw.toString();
        } catch (Exception e) {
            return null;



Wednesday, March 13, 2019

Create new Database from command line Oracle 11g Express

I share example how to create new user from command line, you need SQL*Plus or JDeveloper and super user, I'm using Oracle 11g Express for that use the user SYSTEM.


Step 1:

connect SYSTEM/password; 

Step 2:

CREATE USER your_schema IDENTIFIED BY your_password; 

Step 3:


Step 4:


Step 5:


You try connect with the new user.

That's it. 

Monday, March 4, 2019

ORA-28001: The password has expired

I share solution next error:


1. First connect from SQL Developer or SQL PLUS. Use the user SYSTEM or SYSDBA

2. SQL> connect / as SYSDBA

3. Run next query:

SELECT username,
FROM   dba_users
WHERE  account_status LIKE '%EXPIRED%';

4. Find your User and Check account_status

5. And the last. alter the table with next query

ALTER USER your_user IDENTIFIED BY your_new_or_same_password account unlock;

That is it.

Multiple Data Sources in Spring Boot 3 with Java 21

  In this blog post, we'll explore the configuration and setup for a Spring Boot 3 application with Java 21 that uses multiple data sour...