Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ./java -jar /Samplejavaprogram/Sample.jar
- no main manifest attribute, in /Samplejavaprogram/Sample.jar
- package org.myorg;
- import java.io.*;
- import java.util.*;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import java.util.logging.Level;
- import java.util.*;
- public class Sample {
- public static void main (String[] args) throws IOException {
- int CountComputers;
- FileInputStream fstream = new FileInputStream(
- "/export/hadoop-1.0.1/bin/countcomputers.txt");
- DataInputStream input = new DataInputStream(fstream);
- BufferedReader br = new BufferedReader(new InputStreamReader(input));
- String result=br.readLine();
- CountComputers=Integer.parseInt(result);
- input.close();
- fstream.close();
- Connection con = null;
- Statement st = null;
- ResultSet rs = null;
- String url = "jdbc:postgresql://192.168.1.8:5432/NexentaSearch";
- String user = "postgres";
- String password = "valter89";
- ArrayList<String> paths = new ArrayList<String>();
- try
- {
- con = DriverManager.getConnection(url, user, password);
- st = con.createStatement();
- rs = st.executeQuery("select path from tasks order by id");
- while (rs.next()) { paths.add(rs.getString(1)); };
- PrintWriter zzz = null;
- try
- {
- zzz = new PrintWriter(new FileOutputStream("/export/hadoop-1.0.1/bin/readwaysfromdatabase.txt"));
- }
- catch(FileNotFoundException e)
- {
- System.out.println("Error");
- System.exit(0);
- }
- for (int i=0; i<paths.size(); i++)
- {
- zzz.println("paths[i]=" + paths.get(i) + "n");
- }
- zzz.close();
- }
- catch (SQLException e)
- {
- System.out.println("Connection Failed! Check output console");
- e.printStackTrace();
- }
- }
- }
- group 'MyApplication'
- version '1.0-SNAPSHOT'
- apply plugin: 'java'
- apply plugin: 'application'
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- mainClassName ="com.common.Application"
- buildscript {
- repositories {
- mavenCentral()
- }
- }
- repositories {
- mavenCentral()
- }
- // Include dependent libraries in archive.
- jar {
- manifest {
- attributes "Main-Class": "$mainClassName"
- }
- from {
- configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
- }
- }
- dependencies {
- testCompile group: 'junit', name: 'junit', version: '4.12'
- //JSON
- compile group: 'org.json', name: 'json', version: '20090211'
- //Log4j
- compile group: 'log4j', name: 'log4j', version: '1.2.16'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement