Skip to content
Snippets Groups Projects
Commit fb8f2310 authored by hayyuhanifah's avatar hayyuhanifah
Browse files

dump sql dan kelas DBModule

parent 2d30f7da
No related merge requests found
......@@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Apr 25, 2015 at 11:46 AM
-- Generation Time: Apr 25, 2015 at 01:40 PM
-- Server version: 5.5.32
-- PHP Version: 5.4.16
......@@ -70,13 +70,15 @@ INSERT INTO `resource` (`res_id`, `res_name`) VALUES
--
CREATE TABLE IF NOT EXISTS `trade` (
`id` int(5) NOT NULL AUTO_INCREMENT,
`offer_id` int(3) NOT NULL AUTO_INCREMENT,
`username` varchar(20) NOT NULL,
`offres_id` varchar(5) NOT NULL,
`noffres` int(5) NOT NULL,
`needres_id` varchar(5) NOT NULL,
`nneedres` int(5) NOT NULL,
`status` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
`offer_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`offer_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
......
File added
compile.on.save=true
user.properties.file=C:\\Users\\Gifari\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
file.reference.org.json-20120521.jar=C:\\Users\\HP\\Downloads\\org.json-20120521.jar
user.properties.file=C:\\Users\\HP\\AppData\\Roaming\\NetBeans\\8.0.1\\build.properties
......@@ -31,7 +31,8 @@ file.reference.org.json-20120521.jar=C:\\Users\\Gifari\\Downloads\\org.json-2012
includes=**
jar.compress=false
javac.classpath=\
${file.reference.org.json-20120521.jar}
${file.reference.org.json-20120521.jar}:\
${libs.MySQLDriver.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
......
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package grand.quest;
import java.sql.*;
/**
*
* @author Hayyu Luthfi Hanifah
*/
public class DBModule {
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/grandquest";
// Database credentials
static final String USER = "root";
static final String PASS = "";
// Some attributes
public Connection con = null;
public Statement st = null;
public void connect() throws ClassNotFoundException, SQLException{
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Connecting to database...");
con = DriverManager.getConnection(DB_URL,USER,PASS);
}
public static void main(String[] args) throws ClassNotFoundException, SQLException{
DBModule db = new DBModule();
db.connect();
System.out.println("Creating statement...");
db.st = db.con.createStatement();
String sql;
sql = "SELECT * FROM resource";
ResultSet rs = db.st.executeQuery(sql);
while(rs.next()){
//Retrieve by column name
String id = rs.getString("res_id");
String name = rs.getString("res_name");
//Display values
System.out.print("ID: " + id);
System.out.print(", Name: " + name);
}
}
}
......@@ -10,7 +10,7 @@ package grand.quest;
* @author Gifari
*/
import java.lang.*;
import java.io.*;s
import java.io.*;
import java.net.*;
import org.json.JSONException;
import org.json.JSONObject;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment