diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml
new file mode 100644
index 0000000..746e72c
--- /dev/null
+++ b/.github/workflows/blank.yml
@@ -0,0 +1,36 @@
+# This is a basic workflow to help you get started with Actions
+
+name: CI
+
+# Controls when the workflow will run
+on:
+ # Triggers the workflow on push or pull request events but only for the "master" branch
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+ # Allows you to run this workflow manually from the Actions tab
+ workflow_dispatch:
+
+# A workflow run is made up of one or more jobs that can run sequentially or in parallel
+jobs:
+ # This workflow contains a single job called "build"
+ build:
+ # The type of runner that the job will run on
+ runs-on: ubuntu-latest
+
+ # Steps represent a sequence of tasks that will be executed as part of the job
+ steps:
+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
+ - uses: actions/checkout@v4
+
+ # Runs a single command using the runners shell
+ - name: Run a one-line script
+ run: echo Hello, world!
+
+ # Runs a set of commands using the runners shell
+ - name: Run a multi-line script
+ run: |
+ echo Add other actions to build,
+ echo test, and deploy your project.
diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml
new file mode 100644
index 0000000..78a6bab
--- /dev/null
+++ b/.github/workflows/maven-publish.yml
@@ -0,0 +1,35 @@
+# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
+# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
+
+name: Maven Package
+
+on:
+ release:
+ types: [created]
+ workflow_dispatch:
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up JDK 11
+ uses: actions/setup-java@v4
+ with:
+ java-version: '11'
+ distribution: 'temurin'
+ server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
+ settings-path: ${{ github.workspace }} # location for the settings.xml file
+
+ - name: Build with Maven
+ run: mvn -B package --file pom.xml
+
+ # - name: Publish to GitHub Packages Apache Maven
+ # run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
+ # env:
+ # GITHUB_TOKEN: ${{ github.token }}
diff --git a/Jenkinsfile-homeloan b/Jenkinsfile-homeloan
new file mode 100644
index 0000000..499097d
--- /dev/null
+++ b/Jenkinsfile-homeloan
@@ -0,0 +1,36 @@
+pipeline {
+ agent any
+
+ tools {
+ // Install the Maven version configured as "M3" and add it to the path.
+ maven "maven3.8.1"
+ }
+
+stages {
+ stage('fetch the code') {
+ steps {
+ // One or more steps need to be included within the steps block.
+ git credentialsId: 'github-cred', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+
+ stage('Build the code') {
+ steps {
+ // One or more steps need to be included within the steps block.
+ echo "build"
+ sh 'mvn clean package'
+ }
+ }
+
+ stage('Post Build') {
+ steps {
+ // One or more steps need to be included within the steps block.
+ echo "post-build"
+ deploy adapters: [tomcat7(credentialsId: 'admin-tomcat-lwplabs', path: '', url: 'http://ip-172-31-1-167.ap-south-1.compute.internal:8080/')], contextPath: 'login', onFailure: false, war: '**/*.war'
+ }
+ }
+
+}
+
+
+}
diff --git a/Jenkinsfile-parameterized-tomcat-deploy b/Jenkinsfile-parameterized-tomcat-deploy
new file mode 100644
index 0000000..552f680
--- /dev/null
+++ b/Jenkinsfile-parameterized-tomcat-deploy
@@ -0,0 +1,64 @@
+pipeline {
+ agent any
+ parameters {
+ choice choices: ['develop', 'release', 'master'], description: 'Please provide the branch name so that we can deploy', name: 'branch'
+ }
+
+// not required in case of parameterized
+
+ triggers {
+ pollSCM 'H/2 * * * * '
+ }
+
+ tools {
+ maven 'maven'
+ }
+
+ environment {
+ project_type = 'java'
+ DEPLOY_TO = 'production'
+ }
+
+ stages {
+ stage('git fetch') {
+ steps {
+ git branch: "${params.branch}", credentialsId: '4991f864-6845-456a-90df-f0f62edcdc79', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+
+ stage('Build the code') {
+ when{
+ environment name: 'project_type', value: 'java'
+ }
+ steps {
+ sh 'mvn -Dmaven.test.failure.ignore=true clean package'
+ echo "deploying to ${DEPLOY_TO} Env "
+ deploy adapters: [tomcat8(credentialsId: 'tomcat-cred', path: '', url: 'http://172.31.32.223:8080')], contextPath: 'login-release-branch', onFailure: false, war: '**/*.war'
+ }
+ }
+
+ }
+ post {
+ always {
+ echo "You can always see me"
+ }
+ success {
+
+
+
+ echo "I am running because the job ran successfully"
+ //sh '/usr/local/bin/aws s3 cp /jenkins-home/workspace/stage-tavisca/target/LoginRegisterApp.war s3://9am-weekend-jul/$JOB_NAME/${BUILD_NUMBER}/'
+
+
+
+
+ }
+ unstable {
+ echo "Gear up ! The build is unstable. Try fix it"
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+
+}
diff --git a/README.md b/README.md
index ba52519..ca93d0e 100644
--- a/README.md
+++ b/README.md
@@ -2,15 +2,30 @@
install MySQL version 8.0.21 (ie. 8.0.x)
-database username: root
-database password: admin
+database username: admin
+database password: welcome1
If you are using another user then needs to be changed in java file: DbUtil.java
-mysql> create database tempdb;
+mysql> create database flipkart;
-mysql> use tempdb;
+mysql> use flipkart;
mysql> create table user(name varchar(100),password varchar(100), address varchar(1000), age int, profession varchar(100));
mysql> select * from User;
+
+Go to server
+
+1. yum install git -y
+2. cd $HOME
+3. git clone https://github.com/mailrahulsre/java-db-Login.git
+4. cd /root/java-db-Login/src/main
+5. Update files - with DB end POINT
+ - java/com/example/DbUtil.java
+ - java/com/example/application.properties
+ - webapp/WEB-INF/web.xml
+
+ 6. git add .
+ 7. git commit . -m "new db details"
+ 8. git push origin master
diff --git a/jenkinsfile-11am2022-jan b/jenkinsfile-11am2022-jan
new file mode 100644
index 0000000..904285a
--- /dev/null
+++ b/jenkinsfile-11am2022-jan
@@ -0,0 +1,29 @@
+pipeline {
+ agent any
+
+ tools {
+ maven 'maven-3.8.3'
+ }
+
+ stages {
+
+ stage('fetching the code') {
+ steps {
+ git credentialsId: 'github-cred', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+
+ stage('build the code') {
+ steps {
+ sh 'mvn clean package'
+ }
+ }
+
+ stage('deploy the code') {
+ steps {
+ deploy adapters: [tomcat8(credentialsId: 'admin-tomcat-dev-lwplabs',
+ path: '', url: 'http://172.31.91.71:8080')], contextPath: 'login-lwplabs', onFailure: false, war: '**/*.war'
+ }
+ }
+ }
+}
diff --git a/jenkinsfile-chef b/jenkinsfile-chef
new file mode 100644
index 0000000..62189cd
--- /dev/null
+++ b/jenkinsfile-chef
@@ -0,0 +1,34 @@
+pipeline {
+ agent any
+
+ tools {
+ // Install the Maven version configured as "M3" and add it to the path.
+ maven "MAVEN_PATH"
+ }
+
+ stages {
+ stage('fetch the code') {
+ steps {
+ git credentialsId: 'github-cred', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+ stage('Build the code') {
+ steps {
+ //tool name: 'maven', type: 'maven'
+ sh 'mvn clean package'
+ }
+ }
+ }
+ post {
+ success {
+ s3Upload consoleLogLevel: 'INFO', dontSetBuildResultOnFailure: false, dontWaitForConcurrentBuildCompletion: false, entries: [[bucket: 'artifactory-9am-weekday-jul', excludedFile: 'target', flatten: true, gzipFiles: false, keepForever: false, managedArtifacts: false, noUploadOnFailure: true, selectedRegion: 'ap-south-1', showDirectlyInBrowser: false, sourceFile: '**/*.war', storageClass: 'STANDARD', uploadFromSlave: false, useServerSideEncryption: false]], pluginFailureResultConstraint: 'FAILURE', profileName: 's3profile', userMetadata: []
+ }
+ unstable {
+ echo "Gear up ! The build is unstable. Try fix it"
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+
+}
diff --git a/jenkinsfile-chef-example b/jenkinsfile-chef-example
new file mode 100644
index 0000000..62189cd
--- /dev/null
+++ b/jenkinsfile-chef-example
@@ -0,0 +1,34 @@
+pipeline {
+ agent any
+
+ tools {
+ // Install the Maven version configured as "M3" and add it to the path.
+ maven "MAVEN_PATH"
+ }
+
+ stages {
+ stage('fetch the code') {
+ steps {
+ git credentialsId: 'github-cred', url: 'https://github.com/mailrahulsre/java-db-Login.git'
+ }
+ }
+ stage('Build the code') {
+ steps {
+ //tool name: 'maven', type: 'maven'
+ sh 'mvn clean package'
+ }
+ }
+ }
+ post {
+ success {
+ s3Upload consoleLogLevel: 'INFO', dontSetBuildResultOnFailure: false, dontWaitForConcurrentBuildCompletion: false, entries: [[bucket: 'artifactory-9am-weekday-jul', excludedFile: 'target', flatten: true, gzipFiles: false, keepForever: false, managedArtifacts: false, noUploadOnFailure: true, selectedRegion: 'ap-south-1', showDirectlyInBrowser: false, sourceFile: '**/*.war', storageClass: 'STANDARD', uploadFromSlave: false, useServerSideEncryption: false]], pluginFailureResultConstraint: 'FAILURE', profileName: 's3profile', userMetadata: []
+ }
+ unstable {
+ echo "Gear up ! The build is unstable. Try fix it"
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+
+}
diff --git a/jenkinsfile-dev-b94 b/jenkinsfile-dev-b94
new file mode 100644
index 0000000..e9d1599
--- /dev/null
+++ b/jenkinsfile-dev-b94
@@ -0,0 +1,36 @@
+pipeline {
+ agent any
+
+ tools {
+ // Install the Maven version configured as "M3" and add it to the path.
+ maven "maven"
+ }
+
+ triggers {
+ githubPush()
+ }
+
+ stages {
+ stage('fetch the code') {
+ steps {
+ git branch: 'develop1', credentialsId: 'github-cred', url: 'https://github.com/devopscloudsre/java-db-Login.git'
+ }
+ }
+
+ stage('build the code') {
+ steps {
+ sh 'mvn clean package'
+ }
+ post {
+ // If Maven was able to run the tests, even if some of the test
+ // failed, record the test results and archive the jar file.
+ success {
+ deploy adapters: [tomcat9(credentialsId: 'tomcat-admin-user', path: '', url: 'http://172.31.29.76:8080')], contextPath: '/dev-login', onFailure: false, war: '**/*.war'
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/jenkinsfile-stage-prod-b94 b/jenkinsfile-stage-prod-b94
new file mode 100644
index 0000000..7ded2ef
--- /dev/null
+++ b/jenkinsfile-stage-prod-b94
@@ -0,0 +1,34 @@
+pipeline {
+ agent any
+
+ tools {
+ // Install the Maven version configured as "M3" and add it to the path.
+ maven "maven"
+ }
+
+ parameters {
+ choice(name: 'BRANCH', choices: ['master', 'stage'], description: 'Choose branch')
+ }
+
+ stages {
+ stage('fetch the code') {
+ steps {
+ git branch: '${params.BRANCH}', credentialsId: 'github-cred', url: 'https://github.com/devopscloudsre/java-db-Login.git'
+ }
+ }
+
+ stage('build the code') {
+ steps {
+ sh 'mvn clean package'
+ }
+ post {
+ success {
+ deploy adapters: [tomcat9(credentialsId: 'tomcat-admin-user', path: '', url: 'http://172.31.29.76:8080')], contextPath: '/${params.BRANCH}-login', onFailure: false, war: '**/*.war'
+ }
+ failure {
+ echo "OMG ! The build failed"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ebb92b6..5b644e5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,24 +3,24 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.access
- LoginRegisterApp
+ login
war
- 1.1
+ 1.0
LoginRegisterApp Maven Webapp
http://maven.apache.org
-
+
-
- mysql
- mysql-connector-java
- 8.0.20
-
+
+ mysql
+ mysql-connector-java
+ 8.0.20
+
- javax.servlet
- javax.servlet-api
- 3.0.1
-
+ javax.servlet
+ javax.servlet-api
+ 3.0.1
+
junit
@@ -29,8 +29,32 @@
test
-
+
- LoginRegisterApp
+ ${project.artifactId}##${project.version}
+
+
+
+ org.apache.tomcat.maven
+ tomcat7-maven-plugin
+ 2.2
+
+ /${project.artifactId}##${project.version}
+ http://172.31.19.199:8080/manager/text
+ admin
+ *******
+ true
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
diff --git a/src/main/java/com/example/DbUtil.java b/src/main/java/com/example/DbUtil.java
index 4fda626..3e28b3a 100644
--- a/src/main/java/com/example/DbUtil.java
+++ b/src/main/java/com/example/DbUtil.java
@@ -9,9 +9,9 @@
public class DbUtil {
static Connection con=null;
static String driver = "com.mysql.cj.jdbc.Driver";
- static String url = "jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/flipkart";
- static String username = "admin";
- static String password = "test123test";
+ static String url = "jdbc:mysql://lwplabs.cojh5a5pj8rf.us-east-1.rds.amazonaws.com:3306/lwplabs";
+ static String username = "master";
+ static String password = "welcome1";
static {
try {
diff --git a/src/main/java/com/example/DbUtil.java-bkp b/src/main/java/com/example/DbUtil.java-bkp
new file mode 100644
index 0000000..d881c0c
--- /dev/null
+++ b/src/main/java/com/example/DbUtil.java-bkp
@@ -0,0 +1,83 @@
+package com.example;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class DbUtil {
+ static Connection con=null;
+ static String driver = "com.mysql.cj.jdbc.Driver";
+ static String url = "jdbc:mysql://learnwithproject-com.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/flipkart";
+ static String username = "admin";
+ static String password = "welcome1";
+
+ static {
+ try {
+ /*
+ Properties prop = new Properties();
+ prop.load(DbUtil.class.getResourceAsStream("application.properties"));
+ String driver = prop.getProperty("database.driver");
+ String url = prop.getProperty("database.url");
+ String username = prop.getProperty("database.username");
+ String password = prop.getProperty("database.password");
+ */
+ Class.forName(driver);
+ con = DriverManager.getConnection(url, username, password);
+ System.out.println("database connected...");
+
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch(SQLException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ public static int register(String name, String password, String address, int age, String profession) {
+
+ int rows = 0;
+
+ try {
+ PreparedStatement pst = con.prepareStatement("INSERT INTO user VALUES(?,?,?,?,?)");
+
+ pst.setString(1,name);
+ pst.setString(2, password);
+ pst.setString(3, address);
+ pst.setInt(4, age);
+ pst.setString(5, profession);
+
+ rows = pst.executeUpdate();
+
+ }catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return rows;
+ }
+
+ public static int login(String name, String password) {
+
+ int rows = 0;
+
+ try {
+ PreparedStatement pst = con.prepareStatement("SELECT * FROM user WHERE name = ? AND password = ?");
+
+ pst.setString(1,name);
+ pst.setString(2, password);
+
+
+ ResultSet rs = pst.executeQuery();
+
+ if(rs.next())
+ rows = 1;
+
+ }catch(Exception e) {
+ e.printStackTrace();
+ }
+
+ return rows;
+ }
+}
diff --git a/src/main/java/com/example/application.properties b/src/main/java/com/example/application.properties
index fd3101a..e09ed78 100644
--- a/src/main/java/com/example/application.properties
+++ b/src/main/java/com/example/application.properties
@@ -1,4 +1,4 @@
database.driver=com.mysql.cj.jdbc.Driver
-database.url=jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/flipkart
-database.username=admin
-database.password=test123test
+database.url=jdbc:mysql://lwplabs.cojh5a5pj8rf.us-east-1.rds.amazonaws.com:3306/lwplabs
+database.username=master
+database.password=welcome1
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index 249c9f6..957a79f 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -6,19 +6,19 @@
Archetype Created Web Application
dbUser
- admin
+ master
dbPassword
- welcome123
+ welcome1
dbURL
- jdbc:mysql://flipkart.cqsb5fmzx3vh.ap-south-1.rds.amazonaws.com:3306/
+ jdbc:mysql://lwplabs.cojh5a5pj8rf.us-east-1.rds.amazonaws.com:3306
dbName
- flipkart
+ lwplabs
LoginServlet
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 17ed961..08cd072 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -1,7 +1,7 @@
- Welcome Page
+ Prod Lwplabs test 2......
Login
Register
-
\ No newline at end of file
+