Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sameerbiradar200 committed Sep 25, 2024
1 parent 5f3804c commit 1ad083f
Show file tree
Hide file tree
Showing 20 changed files with 167 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions java8.iml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<component name="AdditionalModuleElements">
<content url="file://$MODULE_DIR$" dumb="true">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
29 changes: 29 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>java8</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>22</maven.compiler.source>
<maven.compiler.target>22</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<!-- Add dependencies here if needed -->

<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>

</dependencies>

</project>
Binary file added src/main/java/NewApp.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package interview_Coding_Questions;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class FrequencyOfEachCharInArray {
public static void main(String[] args) {

List<Integer> arr = Arrays.asList(1,2,3,4,5,62,4,1,0,9,8,7,6,8,3,2,1);
Map<Integer, Long> fre = arr.stream().collect(Collectors.groupingBy(Function.identity(),Collectors.counting()));

System.out.println(fre);

System.out.println("another method");

List<Integer> array = Arrays.asList(1,2,3,4,5,62,4,1,0,9,8,7,6,8,3,2,1);
Map<Integer,Integer> m =new HashMap<>();
for (int a:array){
System.out.println(a);
}

System.out.println(m);

}
}
File renamed without changes.
59 changes: 59 additions & 0 deletions src/main/java/jdbcPostgresql/PostgresqlOne.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package jdbcPostgresql;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class PostgresqlOne {
public static void main(String[] args) {

String url = "jdbc:postgresql://localhost:5432/name";
String user = "postgres";
String password = "sameer";
try(Connection con = DriverManager.getConnection(url,user,password)) {
if(con !=null){
System.out.println("database connection is right");
Statement statement =con.createStatement();
String createTable = "CREATE TABLE IF NOT EXISTS name (" +
"id SERIAL PRIMARY KEY, " + // Optionally keep this if you want a unique identifier
"name VARCHAR(50) NOT NULL, " +
"age INT NOT NULL)";


statement.execute(createTable);
System.out.println("Table 'name' created or already exists.");

String addData ="INSERT INTO name (name, age) "
+ "VALUES ('sameer', 23), "
+ "('ovi', 11), "
+ "('rahee', 19)";

statement.execute(addData);
System.out.println("data added in name DB");

//for printing data from name DB

String select ="SELECT * FROM name";
ResultSet resultSet =statement.executeQuery(select);

while (resultSet.next()){
int id =resultSet.getInt("id");
String name =resultSet.getString("name");
int age =resultSet.getInt("age");
System.out.println(String.format("Id : %d \n Name : %s\n Age : %d",id,name,age));
}




}else{
System.out.println("failed to make connection");
}

}catch (Exception e){
System.out.println(e.getMessage());
}

}
}
Binary file not shown.
Binary file not shown.
Binary file added target/classes/interview_Coding_Questions/Hi.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added target/classes/jdbcPostgresql/PostgresqlOne.class
Binary file not shown.
Binary file added target/classes/main/java/NewApp.jar
Binary file not shown.

0 comments on commit 1ad083f

Please sign in to comment.