Buck,
OMG!
You're smarter than all the experts. Your sample worked with the appropriate changes for connection properties, AND following your example, I was able to get the code I had developed from the Craig Pelkie video/class workbook to function as well! (He didn't know what the problem was) If you're ever in Portland, OR., dinner is on me.
Thank you!!!
-----Original Message-----
From: JAVA400-L [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Buck Calabro
Sent: Tuesday, September 02, 2014 2:17 PM
To: java400-l@xxxxxxxxxxxx
Subject: Re: iSeries to MSSQL - No suitable driver found for jdbc
On 9/2/2014 4:48 PM, Graves, Chuck wrote:
Thanks for the reply. The jar file is OK, I see the classes as you
said I would, the java source was copied (drag/drop) and re-compiled
on the iSeries. All good. It runs but gives the "no suitable driver
found for" and lists the connection parameters (connection string)...
the same string works from my PC. Evan calling it with the -cp
parameter (java -cp /java/jdbc/sqljdbc4.jar:. ibmiToSqlServer6)
produces the same results
OK, can you paste the exact message you're getting? And perhaps the source code? Here is a bit of working code from a proof of concept I did. It ran fine on V5R4 as well as now on 7.2
import java.sql.*;
import java.util.Properties;
public class MSSQLtest {
private Connection connection = null;
public static void main(java.lang.String[] args) {
MSSQLtest test = new MSSQLtest();
test.runQuery();
test.cleanup();
}
public MSSQLtest() {
Properties properties = new Properties ();
properties.put("user", "uuuuuu");
properties.put("password", "pppppp");
properties.put("databaseName", "dddddd");
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection =
DriverManager.getConnection("jdbc:sqlserver://10.1.nnn.nnn:1433",
properties);
System.out.println("DATABASE NAME IS:"
+ connection.getMetaData().getDatabaseProductName());
} catch (Exception e) {
System.out.println("Caught exception: " + e.getMessage());
}
}
public void runQuery() {
try {
Statement s = connection.createStatement();
ResultSet rs = s.executeQuery("select * from information_schema.columns");
System.out.println("--------------------");
int i = 0;
while (rs.next()) {
System.out.println(rs.getString("table_name")
+ " " + rs.getString("column_name")
+ " " + rs.getString("data_type")
+ " " + rs.getString("character_maximum_length")
+ " " + rs.getString("numeric_precision")
+ " " + rs.getString("numeric_scale"));
i++;
}
System.out.println("--------------------");
System.out.println("There were " + i + " rows returned.");
System.out.println("Output is complete.");
} catch (SQLException e) {
System.out.println("SQLException exception: ");
System.out.println("Message:....." + e.getMessage());
System.out.println("SQLState:...." + e.getSQLState());
System.out.println("Vendor Code:." + e.getErrorCode());
e.printStackTrace();
}
}
public void cleanup() {
try {
if (connection != null)
connection.close();
} catch (Exception e) {
System.out.println("Caught exception: ");
e.printStackTrace();
}
}
}
I'm also using sqljdbc4.jar. In my case, it's in /java, along with this code; that's where all of my Java code is stored. I don't have a lot of it :-) My CLASSPATH is CLASSPATH=.:/java:/java/sqljdbc4.jar:/java/jt400.jar:/java/db2jcc4.jar:/java/opencsv-2.3.jar
--buck
--
This is the Java Programming on and around the IBM i (JAVA400-L) mailing list To post a message email: JAVA400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at
http://archive.midrange.com/java400-l.
[Rodda Paint Company!]
Chuck Graves
Director of Information Systems
Rodda Paint Co.<
http://www.roddapaint.com>
6107 N. Marine Drive
Portland, Oregon 97203
(503) 737-6042
As an Amazon Associate we earn from qualifying purchases.