Click here to Skip to main content
15,889,216 members
Home / Discussions / Java
   

Java

 
GeneralRe: how to set thread affinity in JAVA Pin
evyatar.v25-Sep-09 21:40
evyatar.v25-Sep-09 21:40 
GeneralRe: how to set thread affinity in JAVA Pin
427748026-Sep-09 0:05
427748026-Sep-09 0:05 
QuestionNeed help with hash table Pin
snssewell24-Sep-09 22:21
snssewell24-Sep-09 22:21 
AnswerRe: Need help with hash table Pin
427748025-Sep-09 0:39
427748025-Sep-09 0:39 
GeneralRe: Need help with hash table Pin
snssewell25-Sep-09 19:30
snssewell25-Sep-09 19:30 
QuestionRead SDF using Java Pin
jason975424-Sep-09 21:30
jason975424-Sep-09 21:30 
AnswerRe: Read SDF using Java Pin
427748025-Sep-09 0:36
427748025-Sep-09 0:36 
GeneralRe: Read SDF using Java Pin
jason975425-Sep-09 4:12
jason975425-Sep-09 4:12 
Thanks so much, I've made progress. I've loaded the driver successfully and compiled the source code with no warnings or errors. However, I'm still unable to connect to the database. I suspect it is the URL string that I'm specifying, more specifically, I don't know what port to connect to?

The following is the code I've cut:



import java.sql.*;
/**
* Class to create connection to a database and
* and demonstrate basic SQL queries
*/
public class connectDS {
/**
* the connection object
*/
static Connection connection = null;
// select DB2 type 2 driver
static final String dbDriver = "net.sourceforge.jtds.jdbc.Driver";
static final String dbUrl = "jdbc:jtds:sqlserver://localhost: 1433/SASDCE.sdf";
// use the SKICLUB database
static final String dbName = "SASDCE.sdf";
// set dbUser to any user on your Windows OS
static final String dbUser = "userid";
// set dbPassword to Windows password for dbUser
static final String dbPassword = "password";

/**
* method to open the connection
*/
public Connection getConnection() {
if ( connection != null )
return connection;
try {
connection = DriverManager.getConnection(
dbUrl, dbUser, dbPassword );
} catch( SQLException e ) {
System.err.println("Cannot connect to database: for SQl server, " + "check that SQl is running and " + "the database exists.");
}
return connection;
}


@SuppressWarnings("finally")
public ResultSet getAllMemberInfo() {
ResultSet rs = null;
try {
Statement statement =
getConnection().createStatement();
String sql = "Select * from Prop1_Wallfinish, Users where Prop1_Wallfinish.SurveyID= Users.SurveyIDS";
System.out.println( sql );
statement.executeQuery( sql );
rs = statement.getResultSet();
} catch( SQLException e ) {
System.out.println(
"SQLException " + e.getMessage() );
} finally {return rs;}
}


public static void main(String[] args) {
connectDS dbdemo = new connectDS();
System.out.println("Getting Database driver" );
try {
Class.forName( dbDriver );
} catch( ClassNotFoundException e ) {
System.err.println("Cannot load database driver: for SQL, " + "your classpath must include " + "SQLLIB\\JAVA12\\DB2JAVA.ZIP." );
}
System.out.println(
"Getting Database connection" );
Connection connection = dbdemo.getConnection();
if ( connection == null )
System.exit(0);
System.out.println( "Database ready" );
try {
// demonstrate a SELECT Statement
dbdemo.getAllMemberInfo();


connection.close();
} catch (Exception e) {
System.err.println(
e.getClass().getName() + ": " +
e.getMessage() );
}
}// end public main



} // end DB
GeneralRe: Read SDF using Java Pin
427748025-Sep-09 8:25
427748025-Sep-09 8:25 
GeneralRe: Read SDF using Java Pin
jason975425-Sep-09 23:47
jason975425-Sep-09 23:47 
GeneralRe: Read SDF using Java Pin
427748026-Sep-09 1:32
427748026-Sep-09 1:32 
GeneralRe: Read SDF using Java Pin
David Skelly28-Sep-09 22:29
David Skelly28-Sep-09 22:29 
QuestionJava Graphics and Desktop Pin
sharkbc24-Sep-09 17:45
sharkbc24-Sep-09 17:45 
AnswerRe: Java Graphics and Desktop Pin
427748024-Sep-09 18:51
427748024-Sep-09 18:51 
GeneralRe: Java Graphics and Desktop Pin
sharkbc24-Sep-09 19:48
sharkbc24-Sep-09 19:48 
GeneralRe: Java Graphics and Desktop Pin
sharkbc24-Sep-09 20:27
sharkbc24-Sep-09 20:27 
GeneralRe: Java Graphics and Desktop Pin
427748025-Sep-09 0:34
427748025-Sep-09 0:34 
GeneralRe: Java Graphics and Desktop [modified] Pin
sharkbc25-Sep-09 15:55
sharkbc25-Sep-09 15:55 
QuestionJ2ME Pin
Matt Cavanagh24-Sep-09 9:51
Matt Cavanagh24-Sep-09 9:51 
AnswerRe: J2ME Pin
427748024-Sep-09 18:50
427748024-Sep-09 18:50 
Questionplz help in java question Pin
arifihsan24-Sep-09 0:35
arifihsan24-Sep-09 0:35 
AnswerRe: plz help in java question Pin
Richard MacCutchan24-Sep-09 1:21
mveRichard MacCutchan24-Sep-09 1:21 
AnswerRe: plz help in java question Pin
427748024-Sep-09 3:37
427748024-Sep-09 3:37 
QuestionLUCKY DRAW system Pin
syarizan23-Sep-09 23:03
syarizan23-Sep-09 23:03 
AnswerRe: LUCKY DRAW system Pin
Richard MacCutchan24-Sep-09 1:22
mveRichard MacCutchan24-Sep-09 1:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.