Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sergio10

macrumors regular
Original poster
Oct 3, 2007
137
0
hi,

I want to connect MySQL database remotely using MCPKit framework:
http://mysql-cocoa.sourceforge.net/

I developed next:
PHP:
	MCPResult *resuilt;
	NSString *campoX;
	
	MCPConnection *theConnec = [[MCPConnection alloc] initToHost:@"localhost" 
													   withLogin:@"root" password:@"xxxx" usingPort:3303]; 
	
	if ([theConnec isConnected])
	{
		NSLog(@"Connected ");
	}
	else
	{
		NSLog(@"Not Connected ");
	}
	
	user = [[resuilt fetchRowAsArray] objectAtIndex:1];
	NSLog(@"Valor: %@", campoX);
I added framework to project. But when I compile source get errors. (XCode doesn't see MCPResult and MCPConnection).
Why? How to fix this problem?
 
Firstly, are you including the source files for the framework somewhere in your source?? (aka using something like #import <MCPKit/MCPKit.h>)

Secondly, I've never used these frameworks, but I think I spot some general Obj-C problems.

NSString *campoX is never initialized, but you include it in the last NSLog. You didn't even init it as nil, so NSLog is going to pass it the message description, and you will throw an exception.

MCPResult *resuilt is never initialized. I would PRESUME from everything in MySQL I've seen that there would be something SOMEWHERE after the connection that would look like...
resuilt = [[MCPResult alloc] initWithConnection: theConnec andQuery: @"SELECT * FROM table WHERE .... you get the hint"];


Generally in MySQL you need a connection, and then you make a query. What is returned is a funny array that you call MySQL functions on.
 
Thanks for replying. Do you have any suggestions how to connect to database in other way? Meybe using standard cocoa frameworks?
 
So, I included
#import <MCPKit_bundled/MCPKit_bundled.h>
And then got another error:
obj_class_name_MCPConnection refferenced from:
literal-pointer@_OBJC@CLS_refs@MCPConnection in MyController.o
How to fix this problem?
 
Can you post the contents of your source?

Also, why is it named MyController.o?? Shouldn't it be .m? Thats how the compiler knows what to expect in the file. I hope thats the only problem.
 
Also, why is it named MyController.o?? Shouldn't it be .m? Thats how the compiler knows what to expect in the file. I hope thats the only problem.

That's just the object file.

Most likely the problem is happening because the project isn't linking against the framework. Did you drag the framework into your project's Frameworks group? (And add it to a Copy Files build phase?)
 
That's just the object file.

Most likely the problem is happening because the project isn't linking against the framework. Did you drag the framework into your project's Frameworks group? (And add it to a Copy Files build phase?)

I know what the .o means, but to the best of my knowledge when working with objective-c, your implementation should have .m at the end. I think this is for the compiler to know what language it is expecting in the file.
Aren't .o files compiled objects or something?

Was that warning a compiler warning, or a runtime error?
 
Most likely the problem is happening because the project isn't linking against the framework. Did you drag the framework into your project's Frameworks group? (And add it to a Copy Files build phase?)
Yes
 
HELP-to install MCPKit framework

HELP-to install MCPKit framework
on http://mysql-cocoa.sourceforge.net/
I Downloaded the framework --> MCPKit_src_3.0.1.dmg
--> Documentation, MCP(AppKit,EntrepriseKit,FoundKit), MCPKit.xcodeproj, mysql-local
There is no mySQL_bundled.framework, or --bundled
Also, when I opened the project, missing are:
MCPKit_bundled.framework,MCPKit_system.framework,
MCPKit_FoundationTest,MCPKit_Prefix.pch,several things involving .plist

Beginner-after install, would like examples of use of mysql
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.