PDA

View Full Version : Simple SQL Server Connection Problem


dasmin5
01-30-2009, 06:28 PM
I have created a login/registration system. I have setup the database in SQL server 2008 Pro. I setup the security permssision for the database. I also, setup the SQL Config manager to use Tcp 1433. When I run the app it opens fine on the internet which the app is using ASP.Net. What the heck could I be messing up?:eek:

Simple SQL Server Connection
I put in my info that I setup for the database:server name(localhost), Database name(testdb), username:(flexUser), and the password.
When I hit test connection it says:

"Unable to connect to the database"
java.sql.SQLException: Login failed for user 'flexUser'.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnos tic(SQLDiagnostic.java:365)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(Td sCore.java:2781)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCor e.java:2224)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.ja va:599)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:331)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.ja va:178)
at org.eclipse.datatools.connectivity.db.generic.JDBC Connection.createConnection(JDBCConnection.java:87 )
at org.eclipse.datatools.connectivity.DriverConnectio nBase.internalCreateConnection(DriverConnectionBas e.java:104)
at org.eclipse.datatools.connectivity.DriverConnectio nBase.open(DriverConnectionBase.java:53)
at org.eclipse.datatools.connectivity.db.generic.JDBC ConnectionFactory.createConnection(JDBCConnectionF actory.java:52)
at org.eclipse.datatools.connectivity.internal.Connec tionFactoryProvider.createConnection(ConnectionFac toryProvider.java:77)
at org.eclipse.datatools.connectivity.internal.Connec tionProfile.createConnection(ConnectionProfile.jav a:354)
at com.adobe.datatools.derived.wizards.BaseConnection ProfilePage.testConnectionSimple(BaseConnectionPro filePage.java:70)
at com.adobe.datatools.derived.wizards.BaseConnection ProfilePage.testConnection(BaseConnectionProfilePa ge.java:51)
at org.eclipse.datatools.connectivity.ui.wizards.Conn ectionProfileDetailsPage$1.widgetSelected(Connecti onProfileDetailsPage.java:85)
at org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3293)
at org.eclipse.jface.window.Window.runEventLoop(Windo w.java:820)
at org.eclipse.jface.window.Window.open(Window.java:7 96)
at com.adobe.flexbuilder.dbwizard.ui.DbWizard$8.widge tSelected(DbWizard.java:598)
at org.eclipse.swt.widgets.TypedListener.handleEvent( TypedListener.java:227)
at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3293)
at org.eclipse.jface.window.Window.runEventLoop(Windo w.java:820)
at org.eclipse.jface.window.Window.open(Window.java:7 96)
at com.adobe.flexbuilder.dbwizard.actions.DBWizardAct ion.run(DBWizardAction.java:69)
at org.eclipse.ui.internal.PluginAction.runWithEvent( PluginAction.java:256)
at org.eclipse.ui.internal.WWinPluginAction.runWithEv ent(WWinPluginAction.java:229)
at org.eclipse.jface.action.ActionContributionItem.ha ndleWidgetSelection(ActionContributionItem.java:54 6)
at org.eclipse.jface.action.ActionContributionItem.ac cess$2(ActionContributionItem.java:490)
at org.eclipse.jface.action.ActionContributionItem$5. handleEvent(ActionContributionItem.java:402)
at org.eclipse.swt.widgets.EventTable.sendEvent(Event Table.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.ja va:938)
at org.eclipse.swt.widgets.Display.runDeferredEvents( Display.java:3682)
at org.eclipse.swt.widgets.Display.readAndDispatch(Di splay.java:3293)
at org.eclipse.ui.internal.Workbench.runEventLoop(Wor kbench.java:2389)
at org.eclipse.ui.internal.Workbench.runUI(Workbench. java:2353)
at org.eclipse.ui.internal.Workbench.access$4(Workben ch.java:2219)
at org.eclipse.ui.internal.Workbench$4.run(Workbench. java:466)
at org.eclipse.core.databinding.observable.Realm.runW ithDefault(Realm.java:289)
at org.eclipse.ui.internal.Workbench.createAndRunWork bench(Workbench.java:461)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(Pl atformUI.java:149)
at com.adobe.flexbuilder.standalone.FlexBuilderApplic ation.start(FlexBuilderApplication.java:112)
at org.eclipse.equinox.internal.app.EclipseAppHandle. run(EclipseAppHandle.java:169)
at org.eclipse.core.runtime.internal.adaptor.EclipseA ppLauncher.runApplication(EclipseAppLauncher.java: 106)
at org.eclipse.core.runtime.internal.adaptor.EclipseA ppLauncher.start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.ru n(EclipseStarter.java:363)
at org.eclipse.core.runtime.adaptor.EclipseStarter.ru n(EclipseStarter.java:176)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework( Main.java:508)
at org.eclipse.equinox.launcher.Main.basicRun(Main.ja va:447)
at org.eclipse.equinox.launcher.Main.run(Main.java:11 73)
at org.eclipse.equinox.launcher.Main.main(Main.java:1 148)

drkstr
01-31-2009, 05:44 AM
I don't understand, are you creating an AIR app or trying to expose your server side database to a client side application? If the later, you shouldn't/can't connect to the data base directly. You should use a proxy service (some kind of http script or data service) to handle the connection for you, then send the data back in a format the application will use.


Best Regards,
~Aaron

dasmin5
02-03-2009, 02:21 AM
It's just a simple login/registration. I have a whole website already put together with login/registration, etc. But I did that with Dreamweaver, SQL Server 2008, and Visual Studio 2008. I am new to Flex, so I was just trying to do the same thing with Flex.

I have the "Adobe Flex 3 training from the source" book, but it is not really telling much about setting up something for a login w/registration. I am more of a visual person, but I thought the book would help me.

And to reinterate, on the first problem. I created a database first in SQL 2008(not the express ver.). Then I created what I thought was a Flex App w/ASPNet. The Flex App opened fine.. So I made sure I setup all the permissions for the SQL 2008 database. Then I went to Data->Create App from database->New Connection->Name->. From there I am at the "Simple SQL Server Connection" page. And then comes the long error; that I posted before. Sorry, I am trying to sum this up. But, after that I opened up my Flex app in Visual Studio '08. Worked fine there. So I from there I tinkered with the web config, and even setup persmissions that way. To no surprise, I am still at square one.

Hope you have enough information this time.

Thanks

drkstr
02-03-2009, 07:43 PM
Ok, I think I understand what's going on. You should have some kind of gateway that you send information to through POST or GET. I'm not sure how you would configure this in Visual Studio, but on the flex side you would do something like this:

var loader:URLLoader = new URLLoader();
var postVars:URLVariables = new URLVariables();

postVars.userName = "foo"
postVars.userPass = "bar"

request.method = URLRequestMethod.POST;
request.data = postVars;

loader.addEventListener(Event.COMPLETE, completeHandler );
loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler );

loader.load( new URLRequest( "http://www.domain.com/login.php" ) );

or this:

<mx:HTTPService id="userRequest" url="http://domain.com/login.php" useProxy="false" method="POST">
<mx:request xmlns="">
<userName>foo</userName>
<userPass>bar</userPass>
</mx:request>
</mx:HTTPService>

Then on the server side script you would check the credentials in the DB and send back some kind of response your app can understand (usually XML).

Make sense?


Best Regards,
~Aaron