Saturday, 6 July 2019

Migrating from Postgres 
to MongoDB


select row_to_json(t) from (<query>) t(<colums needed>)
Deploying a .Net 4.6.1 Web-Application
to Windows Server 2016 Datacentre with
SQL Server 2012 Express


1) While installing SQL Express, change the user who starts the server from MSSQLServerXXX to NT AUTHORITY\SYSTEM by clicking on Browse, entering SYSTEM in the text box and clicking on Check User. 

Otherwise the DB server won't start at the end due to insufficient permissions and the setup will fail.

2) Choose Windows Authentication during the SQL Server installation since it is more secure. This way the sa user is not enabled by default and removes a well known attack surface.

3) During installation as "handle" error might be faced. The database log is at C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Log. A common problem faced is of "security.dll not found". For this SSL 3.0 and TLS 1.0 has to be enabled and after the server is installed it has to be patched and the former disabled.

Enable them by going to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\ through regedit and entering a value of fffffff for DisabledByDefault


4)  Create a specific login using Security > Login > New User, select SQL Authentication and give him/her a password. Disable Enforce Password Policy to disable Password Expired messages.

5) Create a specific database user linked to this login by expanding the restored application database,
    clicking on Security > User > New User. 

6) Grant common permissions on the database to him/her using the command
     use <db name>
     grant all on <table name> to <user name>


Wednesday, 29 May 2019

POSTGRES - See permissions on sequences (and other database objects)

SELECT relname, relacl
FROM pg_class
WHERE relkind = 'S'
  AND relacl is not null
  AND relnamespace IN (
      SELECT oid
      FROM pg_namespace
      WHERE nspname NOT LIKE 'pg_%'
        AND nspname != 'information_schema'
);

Monday, 15 April 2019

Creating admin user and new database in mongodb

To create admin user open mongo shell and do 

use admin
db.createUser(
  {
    user: "myUserAdmin",
    pwd: "abc123",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
  }
)
 
 
 
To create database named Collection0 open mongo shell and do 
 
db.createCollection( "Collection0") 
 
 
To see databases do
 
show dbs
 
To see tables do
 
use <database_name> 
show collections
 
 
 


 
 

Thursday, 21 February 2019

In Postgres to see which connections are locking which table use the following command

 select * from pg_stat_activity where pid in (select pid from pg_locks where relation = (SELECT distinct attrelid FROM pg_attribute WHERE attrelid = 'onlineschema.vp_sequence_no'::regclass));

Sunday, 30 December 2018

How to include local library in Maven based Java EE project

Edit pom.xml and include

<configuration>
                 <packagingIncludes>WEB-INF/lib/*.jar</packagingIncludes>

Wednesday, 24 October 2018

What to do when Maven dependency downloads are canceled in process and error comes next time

find ~/.m2  -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \; -print -exec rm {} \;


For windows:
cd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i