Thursday, 27 December 2018

Adding MariaDB JDBC Connector to Paraya 5

It's as easy as pie.

  1. start Payara
    $ cd ~/payara5/bin
    $ ./asadmin start-domain
    Waiting for domain1 to start ...............
    Successfully started the domain : domain1
    domain Location: /home/mrbear/payara5/glassfish/domains/domain1
    Log File: /home/mrbear/payara5/glassfish/domains/domain1/logs/server.log
    Admin Port: 4848
    Command start-domain executed successfully.
  2. install the database driver
    $ ./asadmin add-library /home/mrbear/software/mariadb-java-client-2.3.0.jar
    Command add-library executed successfully.
    or try:
    $ cp ~/Downloads/mariadb-java-client-2.3.0.jar ~/payara5/glassfish/domains/domain1/lib

    The last part will probably require a payara application server reboot, though.

  3. connect to http://localhost:4848
  4. surf to Resources -> JDBC -> JDBC Connection Pools
  5. Create a new one
  6. Settings:
    Pool name[obvious]
    Resource Typejavax.sql.DataSource
    Datasource classnameorg.mariadb.jdbc.MariaDbDataSource

    Leave the rest as default.

  7. Define the following additional properties:
    NameValue
    serverNamelocalhost
    URLjdbc:mariadb://localhost:3306/mmud
    databaseNamemmud
    userusername
    passworditsasecret
  8. Try the "Ping" button to verify that the connection is established.
  9. surf to Resources -> JDBC -> JDBC Resources
  10. Create a new one
  11. Settings:
    NameValue
    JNDI Namethis is the name as the resource is defined in your application
    Pool Namethe pool defined previously, it's a dropdown which is convenient.
  12. Press finish or OK or something
  13. Done!

References

Using MySQL with Payara Server
https://blog.payara.fish/using-mysql-with-payara
Payara - Using Hibernate 5 on Payara Server
https://blog.payara.fish/using-hibernate-5-on-payara-server

Thursday, 20 December 2018

Harddisks

I'm getting more and more harddisks in my computer nowadays. Some are really old, some I've managed to appropriate from family members, and of course when I upgraded to SSD, one more harddisk was added.

It's hard to keep them all straight, so I'm writing this stuff down.

For historical purposes, I guess.

It will be split up into "The New" and "The Old".

"The Old" being the original partition information at the time of acquirement.

The New

ATA Samsung SSD 860500 GBsda
The Operating System and everything essential.
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1026047 1024000 500M 7 HPFS/NTFS/exFAT
/dev/sda2 1026048 771002103 769976056 367.2G 7 HPFS/NTFS/exFAT
/dev/sda3 771002368 771969023 966656 472M 27 Hidden NTFS WinRE
/dev/sda4 771971072 976773119 204802048 97.7G 83 Linux

ATA WDC WD4003FZEX-04 TBsdb
Very important data regarding the /home directories.
DeviceStartEndSectorsSizeType
/dev/sdb12048409520481MBIOS boot
/dev/sdb2409610280951024000500MLinux filesystem
/dev/sdb31028096527343750052724094052.5TLinux filesystem
/dev/sdb45273438208742092185521474836481TLinux filesystem

ATA WDC WD5000AAKS-0500 GBsdc
Still empty for now.
DeviceBootStartEndSectorsSizeIdType
/dev/sdc12048976773167976771120465.8G83Linux

ATA ST2000DM001-1CH12 TBsdd
An old harddrive of my mother-in-law, part of a raid now.
DeviceBootStartEndSectorsSizeIdType
/dev/sdd1 2048 3907024895 3907022848 1.8T fd Linux raid autodetect

The Old

ATA Samsung SSD 860500 GBsda
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 1026047 1024000 500M 7 HPFS/NTFS/exFAT
/dev/sda2 1026048 771002103 769976056 367.2G 7 HPFS/NTFS/exFAT
/dev/sda3 771002368 771969023 966656 472M 27 Hidden NTFS WinRE
/dev/sda4 771971072 976773119 204802048 97.7G 83 Linux

ATA WDC WD4003FZEX-04 TBsdb
DeviceStartEndSectorsSizeType
/dev/sdb12048409520481MBIOS boot
/dev/sdb2409610280951024000500MLinux filesystem
/dev/sdb31028096527343750052724094052.5TLinux filesystem
/dev/sdb45273438208742092185521474836481TLinux filesystem
/dev/sdb574209218567630637055209715200100GLinux filesystem
/dev/sdb67630637056763804467174076163.5GLinux swap

ATA WDC WD5000AAKS-0500 GBsdc
DeviceBootStartEndSectorsSizeIdType
/dev/sdc1*204820290317820290113196.8G7HPFS/NTFS/exFAT
/dev/sdc2202903552203876351972800475M27Hidden NTFS WinRE
/dev/sdc3203878400204799999921600450M27Hidden NTFS WinRE
/dev/sdc4204802048414517247209715200100G83Linux

ATA ST2000DM001-1CH12 TBsdd
DeviceBootStartEndSectorsSizeIdType
/dev/sdd1*204810240204710240000048.8G7HPFS/NTFS/exFAT
/dev/sdd21024020482000568319765478446.6G83Linux
/dev/sdd320005683220535418871853485056883.8Gfd Linux raid autodetect
/dev/sdd4205354188839070269431853485056883.8Gfd Linux raid autodetect

References

Binary Tides - 9 commands to check hard disk partitions and disk space on Linux
https://www.binarytides.com/linux-command-check-disk-partitions/

Thursday, 13 December 2018

Making your labtop battery last longer in Linux

So I went to Devoxx in Belgium, and I took my labtop along. Of course, it's in a Cinema, so there's no electrical sockets in the rooms.

I was looking to prolong the use of my labtop, so I was looking for extend the battery life.

There were several good articles about it (see below in the references.)

I choose to install the Xfce Desktop Environment, and I was pleasantly surprised my labtop managed to hold together for a lot longer.

Fedora has some notes on how to install it, it's basically running the package manager properly, and it's done.

It can be selected from the dropdown menu on the login screen.

I shall put the command line down here, so I do not forget:

sudo dnf install tlp tlp-rdw
sudo systemctl enable tlp

References

FOSS Post - 7 Tips to Reduce Battery Usage on Linux
https://fosspost.org/tutorials/7-tips-to-reduce-battery-usage-on-linux
Xfce Desktop Environment
https://www.xfce.org/
LXDE Desktop Environment for All
https://lxde.org/
Openbox - minimalistic window manager
http://openbox.org/wiki/Main_Page
Xfce In Fedora
https://fedoraproject.org/wiki/Xfce

Thursday, 6 December 2018

Adding MariaDB JDBC Connector to Wildfly 14

  1. install the database driver as a module
    1. create directory WILDFLY_HOME/modules/com/mariadb/main
      $ mkdir -p modules/com/mariadb/main
    2. copy database driver into that one
      $ cp ~/Downloads/mariadb-java-client-2.3.0.jar .
    3. Create the file module.xml in the same folder with the following content:
      <module xmlns="urn:jboss:module:1.3" name="com.mariadb">
          <resources>
              <resource-root path="mariadb-java-client-2.3.0.jar"/>
          </resources>
          <dependencies>
              <module name="javax.api"/>
              <module name="javax.transaction.api"/>
          </dependencies>
      </module>
  2. start Wildfly
    $ cd $WILDFLY_HOME/bin
    $ ./standalone.sh
  3. connect to http://localhost:9990/error/index.html
  4. run ./add-user.sh
    [mrbear@localhost bin]$ ./add-user.sh 

    What type of user do you wish to add? 
     a) Management User (mgmt-users.properties) 
     b) Application User (application-users.properties)
    (a): a

    Enter the details of the new user to add.
    Using realm 'ManagementRealm' as discovered from the existing property files.
    Username : mrbear
    Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
     - The password should be different from the username
     - The password should not be one of the following restricted values {root, admin, administrator}
     - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
    Password : 
    Re-enter Password :  
    What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: 
    About to add user 'mrbear' for realm 'ManagementRealm'
    Is this correct yes/no? yes
    Added user 'mrbear' to file '/home/mrbear/wildfly-14.0.1.Final/standalone/configuration/mgmt-users.properties'
    Added user 'mrbear' to file '/home/mrbear/wildfly-14.0.1.Final/domain/configuration/mgmt-users.properties'
    Added user 'mrbear' with groups  to file '/home/mrbear/wildfly-14.0.1.Final/standalone/configuration/mgmt-groups.properties'
    Added user 'mrbear' with groups  to file '/home/mrbear/wildfly-14.0.1.Final/domain/configuration/mgmt-groups.properties'
    Is this new user going to be used for one AS process to connect to another AS process? 
    e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.
    yes/no? no
  5. click on "Try again" on the Website
  6. log on with the new added user
  7. Configuration - Subsystems - Datasources and drivers - JDBC drivers - [+]
  8. Fill out the following information:
    Driver namemariadb
    Driver Module Namecom.mariadb
    Module Slot
    Driver Class Nameorg.mariadb.jdbc.Driver
    Drive Datasource Class Name
    Driver XA Datasource Class Name
  9. Configuration - Subsystems - Datasources and drivers - Datasources - [+]
  10. Select "Add Datasource" to add a non-XA Datasource
  11. Select "Custom" template
  12. Attributes:
    Name[name]
    JNDI Namejava:/jdbc/[name]
  13. JDBC Driver
    Driver Namemariadb
    Driver Module Name[empty]
    Driver Class Name[empty]
  14. Connection:
    Connection URLjdbc:mariadb://localhost:3306/[databasename]
    User nameroot
    Passworditsasecret
    Security Domain[empty]
  15. Test connection
  16. Reload of server required - so reload the server
  17. Test connection: Successfully tested connection for datasource [name].

References

JDBC Driver / DataSource Setup
https://hal.gitbooks.io/dev/content/recipes/jdbc-driver-setup.html
About MariaDB Connector/J
https://mariadb.com/kb/en/library/about-mariadb-connector-j/
GitHub - Use MariaDB Connector/J Driver
https://github.com/MariaDB/mariadb-connector-j/blob/master/documentation/use-mariadb-connector-j-driver.creole
IronJacamar 1.1 - Userguide - Deploying DS Descriptor
http://www.ironjacamar.org/doc/userguide/1.1/en-US/html_single/index.html#deployingds_descriptor