Friday, April 27, 2012

How to add External Java Classes to GWT Project?

Hi im new in this some one Guide me...

i create a java project
----------------------------------------------------------------------------------------------------------------------------------------
import java.sql.DriverManager;

public class DB_Conn {

private java.sql.Connection con = null;
//private final String url = "jdbc:microsoft:sqlserver://";
private final String serverName = "192.168.1.103";
//private final String portNumber = "1433";
private final String databaseName = "sdportaldb1";
private final String userName = "sddb1ownr";
private final String password = "judgmentDAY786";

// Informs the driver to use server a side-cursor,
// which permits more than one active statement
// on a connection.
//private final String selectMethod = "cursor";

public DB_Conn() {
}

private java.sql.Connection getConnection() {
try {
// Note: this class name changes for ms sql
server 2000 thats it
// It has to match the JDBC library that goes
with ms sql 2000

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con =
DriverManager.getConnection(getConnectionUrl());

if (con != null)
System.out.println("Connection
Successful!");
} catch (Exception e) {
e.printStackTrace();
System.out.println("Error Trace in
getConnection() : "
+ e.getMessage());
}
return con;
}

private String getConnectionUrl() {
String url = "jdbc:sqlserver://" + serverName +
";user=" + userName
+ ";password=" + password +
";databaseName=" + databaseName
+ ";";
return url;
}

/*
Display the driver properties, database details
*/

public void displayDbProperties() {
java.sql.DatabaseMetaData dm = null;
java.sql.ResultSet rs = null;
try {
con = this.getConnection();
if (con != null) {
dm = con.getMetaData();
System.out.println("Driver
Information");
System.out.println("\tDriver Name: " +
dm.getDriverName());
System.out
.println("\tDriver
Version: " + dm.getDriverVersion());
System.out.println("\nDatabase
Information ");
System.out.println("\tDatabase Name: "
+
dm.getDatabaseProductName());
System.out.println("\tDatabase
Version: "
+
dm.getDatabaseProductVersion());
System.out.println("Avalilable
Catalogs ");
rs = dm.getCatalogs();
while (rs.next()) {
System.out.println("\tcatalog:
" + rs.getString(1));
}
rs.close();
rs = null;
closeConnection();
} else
System.out.println("Error: No active
Connection");
} catch (Exception e) {
e.printStackTrace();
}
dm = null;
}

private void closeConnection() {
try {
if (con != null)
con.close();
con = null;
} catch (Exception e) {
e.printStackTrace();
}
}

public static void main(String[] args) throws Exception {
DB_Conn myDbTest = new DB_Conn();
myDbTest.displayDbProperties();
}
}
----------------------------------------------------------------------------------------------------------------------------------------
and now i wana use this class in GWT Project

how i used it some one guide me plz

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment