Skip to content
Snippets Groups Projects
Commit 7508c486 authored by Nathan's avatar Nathan
Browse files

ajout fichiers supplémentaires

parent a870647f
Branches
No related tags found
No related merge requests found
Manifest-Version: 1.0
Main-Class: postgresqlJava.App
<?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>postgresqlJava</groupId>
<artifactId>postgresqlJava</artifactId>
<version>1.0-SNAPSHOT</version>
<name>postgresqlJava</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.23</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>postgresqlJava.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<mainClass>postgresqlJava.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: org.postgresql:postgresql:42.2.23" level="project" />
<orderEntry type="library" scope="RUNTIME" name="Maven: org.checkerframework:checker-qual:3.5.0" level="project" />
</component>
</module>
\ No newline at end of file
package postgresqlJava;
import java.sql.*;
import java.util.UUID;
public class Microblog {
public Connection c;
public Microblog(String ip){
try{
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://"+ip+":5432/microblog","common_user","");
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
System.out.println("Connection succesfull");
}
/**
* Publish a post
* @param user the name of the user
* @param password the password of the user
* @param content the content
* @throws SQLException on SQL Exception
*/
public void publish_post(String user,String password,String content) throws SQLException {
publish_post(user,password,content,null);
}
/**
* Publish a post
* @param user the username of the user
* @param password the password of the user
* @param content the content of the message
* @param uuid the uuid of the user that the post reply to (nullable)
* @throws SQLException on SQLException
*/
public void publish_post(String user, String password, String content, UUID uuid) throws SQLException {
PreparedStatement preparedStatement = c.prepareStatement("SELECT insert_message(?,?,?,?)");
preparedStatement.setString(1,user);
preparedStatement.setString(2,password);
preparedStatement.setString(3,content);
preparedStatement.setObject(4,uuid);
if(! (preparedStatement.execute())){
System.out.println("Error While insert Message");
}else{
ResultSet resultSet = preparedStatement.getResultSet();
while(resultSet.next()){
System.out.println(resultSet.getObject(1));
}
System.out.println("Message Insert");
}
}
/**
* Create a user
* @param username the name of the user
* @param password the password of the user
* @throws SQLException on SQLException
*/
public void createUser(String username, String password) throws SQLException {
PreparedStatement preparedStatement = c.prepareStatement("SELECT create_user(?,?)");
preparedStatement.setString(1,username);
preparedStatement.setString(2,password);
if(! (preparedStatement.execute())){
System.out.println("Error While creating user");
}else{
ResultSet resultSet = preparedStatement.getResultSet();
while(resultSet.next()) {
System.out.println(resultSet.getObject(1));
}
}
}
/**
* Follow a user
* @param userame the name of the user
* @param password the password of the user
* @param uuid the uuid of the user to follow
* @throws SQLException on SQLException
*/
public void follow(String userame,String password,UUID uuid) throws SQLException {
PreparedStatement preparedStatement = c.prepareStatement("SELECT follow(?,?,?)");
preparedStatement.setString(1,userame);
preparedStatement.setString(2,password);
preparedStatement.setObject(3,uuid);
if(! (preparedStatement.execute())){
System.out.println("Error While creating user");
}else{
System.out.println("Follow succes");
}
}
/**
* Get the feed of user
* @param username the username
* @param password the password
* @throws SQLException on SQLException
*/
public void get_feed(String username,String password) throws SQLException {
get_feed(username,password,50);
}
/**
* Get the feed of user
* @param username the username
* @param password the password
* @param limit on SQLException
* @throws SQLException
*/
public void get_feed(String username,String password, int limit) throws SQLException {
PreparedStatement preparedStatement = c.prepareStatement("SELECT feed(?,?) LIMIT ?");
preparedStatement.setString(1,username);
preparedStatement.setString(2,password);
preparedStatement.setInt(3,limit);
if(! (preparedStatement.execute())){
System.out.println("Error While creating user");
}else{
ResultSet resultSet = preparedStatement.getResultSet();
while(resultSet.next()) {
System.out.println("Feed row");
System.out.println(resultSet.getObject(1));
System.out.println("\n");
}
}
}
/**
* Get view Messages
*/
public void get_messages() throws SQLException {
PreparedStatement preparedStatement = c.prepareStatement("SELECT * from messages");
if(! (preparedStatement.execute())){
System.out.println("Error While creating user");
}else {
ResultSet resultSet = preparedStatement.getResultSet();
while (resultSet.next()) {
System.out.println("Message Row");
System.out.println(resultSet.getObject(1));
System.out.print(resultSet.getString(2));
System.out.println(resultSet.getDate(3));
System.out.println(resultSet.getObject(4));
System.out.println(resultSet.getString(5));
System.out.println(resultSet.getObject(6));
System.out.println("\n");
}
}
}
}
Rafael Velazquez
Nestor Ellison
Ramon Fletcher
Roseann Casey
Crystal Case
Homer Levine
Arturo Dale
Jaime Bridges
Charmaine Buckley
Lesa Holcomb
Verna Lynch
Lorene Stein
Goldie Molina
Tania Lindsey
Letha Burgess
Noreen Norton
Giovanni Lynn
Tyson Madden
Bobbi Norris
Luis Golden
Marisol Dunlap
Darius Strickland
Manuela Wyatt
Joaquin Ramsey
Eula Bryan
Sheryl Ingram
Jules Everett
Jayson Everett
Barney Mckay
Lynnette Ellison
Al Tillman
Ida Bauer
Clayton Porter
Felecia Sheppard
Jane Delacruz
Tyler Cardenas
Thelma Dodson
Rickie Snow
Jorge Burton
Chang Ray
Marla Cherry
Sydney Carney
Earline Fletcher
Dominique Mayer
Joseph Bernard
Dante Marsh
Matilda Price
Shelly Sandoval
Edwardo Webster
Preston Ingram
Elba Coffey
Bettye Craig
Donna Hess
Hector Dunlap
Minerva Hickman
Julio Spencer
Lavonne Lindsey
Roscoe Duncan
Shawn Finley
Andrea Wright
Marcella Hooper
Eli Lyons
Christoper Gentry
Esperanza Conway
Beverley Malone
Felix Fitzgerald
Ted Robles
Sherri Nicholson
Leola Hurst
Genaro Gilliam
Ilene Page
Johnathon Hubbard
Eric Terrell
Jillian Pruitt
Therese Riley
Imelda Mccall
Stacy Beck
Lance Frank
Elliott Goodwin
Son Barnett
Wilma Crane
Ashley Delacruz
Hallie Short
Deann Snider
Lamar Kelly
Augustus Ratliff
Clara Jones
Blair Pruitt
Connie Todd
Kelly Miller
Serena Roman
Faye Holden
Erma Banks
August Webster
Dion Burnett
Florine Harper
Lamar Brewer
Jodi Weber
Rick Knowles
Lee Trujillo
Elva Sanders
Katelyn Humphrey
Daphne Mclean
Sybil Cain
Perry Hewitt
Jeremiah Le
Dick Patton
Theron Kirk
Tanisha Lowery
Pedro Orr
Marsha Aguirre
Marcella Chavez
Edgar Garza
Johnnie Rivas
Anna Hyde
Leo Stuart
Marjorie Pittman
Helen Hayes
Lessie Stephens
Alphonso Coffey
Latasha Welch
Chance Stephenson
Stefan Decker
Mavis Johnston
Cornell Gibson
Gayle Charles
Randolph Wood
Natasha Hayes
Tony Abbott
Shelly Spears
Ronald Marshall
Lora Huff
Travis Oneill
Dona Hopkins
Deloris Bartlett
Tisha Franco
Dollie Gomez
Jessie Burt
Darin Rhodes
Alfonso Gaines
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment