Skip to content

Instantly share code, notes, and snippets.

@zarac
Created October 29, 2014 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zarac/277835df063315bf300c to your computer and use it in GitHub Desktop.
Save zarac/277835df063315bf300c to your computer and use it in GitHub Desktop.
/**
* Created by zarac on 10/28/14.
*/
import com.microsoft.sqlserver.jdbc.SQLServerDriver;
import java.sql.*;
public class mainz0r {
public static String connectionUrl = "jdbc:sqlserver://vart.nu:8887;databaseName=GRUPP18C;user=alle;password=hemligt;";
public static Connection con;
public static void main(String[] argv) {
//Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
try {
con = DriverManager.getConnection(connectionUrl);
mainz0r.getInsomnia(); }
catch (SQLException e) {
System.out.println("OH NOES!" + e.getMessage()); }
System.out.println("heafhae"); }
public static void getInsomnia() {
try {
PreparedStatement statement = con.prepareStatement("SELECT * FROM lider WHERE sname = ?");
statement.setString(1, "insomnia");
ResultSet result = statement.executeQuery();
while (result.next()) {
System.out.println("record : " + result.getString(1)); } }
catch (SQLException e) {
System.out.println("ERROR YO! " + e.getMessage());
e.printStackTrace(); } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment