PurabTech is technical blog for Programmer and Coders
Author: Purab
I am Purab from India, Software development is my profession and teaching is my passion.
Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks.
Purab's Github Repo
Youtube Chanel Video Tutorials
Connect to on LinkedIn
https://www.sqlite.org/download.html – donwload “64-bit DLL (x64) for SQLite” and “A bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff.exe program, and the sqlite3_analyzer.exe program.” extract and copy files to “windows/system32 folder”. Edit environment variables and add sqlite3 there.
the schema will be found in test/fixtures/posts.yml. the following command will execute db migration rails db:migrate
command to run -rails console -Post.connection -a=Post -a=Post.new -a.title=”hello” -a.description=”world” -a.save -a -Post.find(1) -Post.find(1).destroy
use “bundle” command when you are uncomment gemfile line.
For devlopment I am using Intellij IDE. I found “File and Code Templates” and “Live Templates” very useful, It is beneficial while doing day-to-day development. It saves some time and be more productive.
I am using keepass for keeping safe my passwords. If you want start keepass on windows startup then follow these steps.
Download and install the latest version of KeePass
After starting the software, untick all lines which start with “lock” in the “Tools / Security”. Save by pressing “OK”.
Select “File / New” to create a new database and choose carefully the location. Note: It’s not possible to change using key file instead of password for existing databases.
Untick “Master Password”, tick the “Key file / provider”, and select “Create”. Select the location carefully. Then press “OK”.
Press Windows + R, and type the “shell:startup” command without quotes. It will open the startup folder.
Set this below as a location for the shortcut. Replace the database and key file location with yours
I am using centos 7.4 server. you can use following commands for installing ssl certicate.
#cd /etc/nginx/conf.d/
[root@vps147238 conf.d]# cp m.eparinay.com.conf qa.eparinay.com.conf [root@vps147238 conf.d]# vim qa.eparinay.com.conf [root@vps147238 conf.d]# sudo certbot --nginx -d qa.eparinay.com -d qa.eparinay.com Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/eparinay.com.conf with version 1.11.0 of Certbot. This might not work. Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/purabtech.com.conf with version 1.11.0 of Certbot. This might not work. Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/www.eparinay.com-0001.conf with version 1.11.0 of Certbot. This might not work. Requesting a certificate for qa.eparinay.com Performing the following challenges: http-01 challenge for qa.eparinay.com Waiting for verification… Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/conf.d/qa.eparinay.com.conf Traffic on port 80 already redirecting to ssl in /etc/nginx/conf.d/qa.eparinay.com.conf
Congratulations! You have successfully enabled https://qa.eparinay.com
IMPORTANT NOTES:
Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/qa.eparinay.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/qa.eparinay.com/privkey.pem Your certificate will expire on 2022-07-31. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew all of your certificates, run "certbot renew"
If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
[root@vps147238 conf.d]# vim qa.eparinay.com.conf [root@vps147238 conf.d]# service nginx restart Redirecting to /bin/systemctl restart nginx.service [root@vps147238 conf.d]#
I am using Nginx server and with that, I am using an angular application. The application is running fine but in the console, I got the following error
Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser
To solve this error I added following code in my nginx configuration.
Above command will enable the required optional components, download the latest Linux kernel, set WSL 2 as your default, and install a Linux distribution for you (Ubuntu by default)
install sdkman – ref taken from https://sdkman.io/install
curl -s "https://beta.sdkman.io" | bash
#sdk selfupdate force
install micronaut with sdkman
#sdk update
#sdk install micronaut
OR
Download the latest binary from Micronaut Website – https://github.com/micronaut-projects/micronaut-starter/releases/download/v3.2.0/micronaut-cli-3.2.0.zip
Extract the binary to appropriate location (For example: C:\PURAB\micronaut-cli-3.2.0)
Create an environment variable MICRONAUT_HOME which points to the installation directory i.e. C:\PURAB\micronaut-cli-3.2.0
Update the PATH environment variable, append %MICRONAUT_HOME%\bin.
String sql = "select * from user where username=? and password=?"; PreparedStatement ps =connection.prepareStatement(sql); ps.setString(1, username); ps.setString(2, password); ResultSet rs=ps.executeQuery(sql); while (rs.next()) { user= new User(); user.setId(rs.getInt(1)); user.setName(rs.getString(2)); user.setEmail(rs.getString(3)); user.setQualification(rs.getString(5)); user.setRole(rs.getString(6)); }
I got following eror:
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? and password=?' at line 1 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1200)
Solution and what is wrong?
for this line ResultSet rs=ps.executeQuery(sql); I do not need to add SQL query there.
I removed SQL keyword it code started working fine…
String sql = "select * from user where username=? and password=?"; PreparedStatement ps =connection.prepareStatement(sql); ps.setString(1, username); ps.setString(2, password); ResultSet rs=ps.executeQuery();